mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 15:58:18 +00:00
feat(transcode): add PDF proxy support for TXT and CSV files
This commit is contained in:
@@ -34,6 +34,9 @@ describe('transcodePdfWorkflow', () => {
|
||||
downloadMediaToTmpActivity: Object.assign(vi.fn(), {
|
||||
_activityName: 'downloadMediaToTmpActivity',
|
||||
}),
|
||||
generatePdfProxyActivity: Object.assign(vi.fn(), {
|
||||
_activityName: 'generatePdfProxyActivity',
|
||||
}),
|
||||
cleanupTmpDirActivity: Object.assign(vi.fn(), { _activityName: 'cleanupTmpDirActivity' }),
|
||||
createEmbeddingTaskIfEnabledActivity: Object.assign(vi.fn(), {
|
||||
_activityName: 'createEmbeddingTaskIfEnabledActivity',
|
||||
@@ -60,6 +63,10 @@ describe('transcodePdfWorkflow', () => {
|
||||
filePath: '/tmp/doc.pdf',
|
||||
tmpDir: '/tmp',
|
||||
})
|
||||
mockActivities.generatePdfProxyActivity.mockResolvedValue({
|
||||
pdfProxyKey: 'document.pdf',
|
||||
pdfFilePath: '/tmp/doc.pdf',
|
||||
})
|
||||
})
|
||||
|
||||
it('should process pdf transcode and sprite generation successfully', async () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ export async function transcodePdfWorkflow(task: WorkflowTask): Promise<void> {
|
||||
generateSpriteActivity,
|
||||
updateAssetMediaActivity,
|
||||
downloadMediaToTmpActivity,
|
||||
generatePdfProxyActivity,
|
||||
createEmbeddingTaskIfEnabledActivity,
|
||||
} = getActivities()
|
||||
|
||||
@@ -35,12 +36,22 @@ export async function transcodePdfWorkflow(task: WorkflowTask): Promise<void> {
|
||||
const download = await executeActivity(workerQueue, downloadMediaToTmpActivity, {
|
||||
assetKey: key,
|
||||
})
|
||||
const { filePath } = download
|
||||
let currentFilePath = download.filePath
|
||||
tmpDir = download.tmpDir
|
||||
|
||||
const pdfProxy = await executeActivity(workerQueue, generatePdfProxyActivity, {
|
||||
assetId: asset.id,
|
||||
assetKey: key,
|
||||
filePath: currentFilePath,
|
||||
mediaType: asset.mediaType || '',
|
||||
filename: asset.name || '',
|
||||
})
|
||||
|
||||
currentFilePath = pdfProxy.pdfFilePath
|
||||
|
||||
const spec = task.payload?.transcode || {}
|
||||
const mediaInfo = await executeActivity(workerQueue, getMediaInfoActivity, {
|
||||
filePath,
|
||||
filePath: currentFilePath,
|
||||
assetId: asset.id,
|
||||
mediaType: asset.mediaType || '',
|
||||
})
|
||||
@@ -51,6 +62,9 @@ export async function transcodePdfWorkflow(task: WorkflowTask): Promise<void> {
|
||||
filesizeInBytes: 0,
|
||||
codec: '',
|
||||
}
|
||||
mediaInfo.pdfTranscode = {
|
||||
key: pdfProxy.pdfProxyKey,
|
||||
}
|
||||
|
||||
if (spec.sprite || spec.poster) {
|
||||
const lastSlashIndex = key.lastIndexOf('/')
|
||||
@@ -68,7 +82,7 @@ export async function transcodePdfWorkflow(task: WorkflowTask): Promise<void> {
|
||||
|
||||
const spriteResult = await executeActivity(workerQueue, generateSpriteActivity, {
|
||||
assetKey: key,
|
||||
filePath,
|
||||
filePath: currentFilePath,
|
||||
spriteSpec,
|
||||
posterSpec,
|
||||
mediaInfo,
|
||||
|
||||
Reference in New Issue
Block a user