mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 15:17:15 +00:00
fix(transcode): co-locate screenshots and derived artifacts in asset storage directory (#399)
* fix(transcode): co-locate screenshots and derived artifacts in asset storage directory * refactor(transcode): centralize derived artifact directory resolution and strengthen upload assertions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { stemFromKey } from '@shumai/core/src/utils/filename'
|
||||
import { getDerivedArtifactDirectory, stemFromKey } from '@shumai/core/src/utils/filename'
|
||||
import { mapConcurrent } from '../utils/async'
|
||||
import { prisma, WorkflowTaskStatus, WorkflowTaskType } from '@shumai/db'
|
||||
import '@shumai/db/src/prisma-json-types'
|
||||
@@ -1275,7 +1275,8 @@ export class TranscodeService {
|
||||
}
|
||||
|
||||
// 6. Upload to S3
|
||||
const s3Key = `files/${params.assetId}/screenshots/${outName}`
|
||||
const assetDir = getDerivedArtifactDirectory(params.assetKey, params.assetId)
|
||||
const s3Key = `${assetDir}/screenshots/${outName}`
|
||||
const fileBuffer = fs.readFileSync(localShotPath)
|
||||
await s3Service.putObject(bucket, s3Key, fileBuffer, fileBuffer.length, 'image/webp')
|
||||
|
||||
@@ -1374,7 +1375,8 @@ export class TranscodeService {
|
||||
}
|
||||
|
||||
// Upload to S3 directly from buffer
|
||||
const s3Key = `files/${params.assetId}/pdf_pages/${webpName}`
|
||||
const assetDir = getDerivedArtifactDirectory(params.assetKey, params.assetId)
|
||||
const s3Key = `${assetDir}/pdf_pages/${webpName}`
|
||||
await s3Service.putObject(bucket, s3Key, webpBuffer, webpBuffer.length, 'image/webp')
|
||||
|
||||
results.push({ key: s3Key, page: pageNum })
|
||||
@@ -1429,7 +1431,8 @@ export class TranscodeService {
|
||||
)
|
||||
|
||||
// 3. Upload to S3
|
||||
const s3Key = `files/${params.assetId}/annotations/${outName}`
|
||||
const assetDir = getDerivedArtifactDirectory(params.assetKey, params.assetId)
|
||||
const s3Key = `${assetDir}/annotations/${outName}`
|
||||
await s3Service.putObject(
|
||||
bucket,
|
||||
s3Key,
|
||||
|
||||
Reference in New Issue
Block a user