mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-22 20:57:45 +00:00
feat(api,webui): implement image compression, auto-refresh for uploads, and infinite pagination for collections/shares
This commit is contained in:
@@ -274,14 +274,14 @@ export class TranscodeService {
|
||||
}
|
||||
|
||||
async transcodeImage(
|
||||
inputFile: string,
|
||||
inputFile: string | Buffer,
|
||||
outputFile: string,
|
||||
width: number,
|
||||
quality: number,
|
||||
height: number | null = null,
|
||||
): Promise<void> {
|
||||
let input: string | Buffer = inputFile
|
||||
if (inputFile.startsWith('http')) {
|
||||
if (typeof inputFile === 'string' && inputFile.startsWith('http')) {
|
||||
const resp = await fetch(inputFile)
|
||||
if (!resp.ok) {
|
||||
throw new Error(`Failed to fetch image from ${inputFile}: ${resp.statusText}`)
|
||||
@@ -512,7 +512,7 @@ export class TranscodeService {
|
||||
}
|
||||
|
||||
// 6. Upload to S3
|
||||
const s3Key = `file/${params.assetId}/screenshots/${outName}`
|
||||
const s3Key = `files/${params.assetId}/screenshots/${outName}`
|
||||
const fileBuffer = fs.readFileSync(localShotPath)
|
||||
await s3Service.putObject(bucket, s3Key, fileBuffer, fileBuffer.length, 'image/webp')
|
||||
|
||||
@@ -556,7 +556,7 @@ export class TranscodeService {
|
||||
.toFile(localOutPath)
|
||||
|
||||
// 5. Upload to S3
|
||||
const s3Key = `file/${params.assetId}/annotations/${outName}`
|
||||
const s3Key = `files/${params.assetId}/annotations/${outName}`
|
||||
const fileBuffer = fs.readFileSync(localOutPath)
|
||||
await s3Service.putObject(bucket, s3Key, fileBuffer, fileBuffer.length, 'image/webp')
|
||||
|
||||
|
||||
@@ -274,8 +274,8 @@ describe('Transcode Workflow', () => {
|
||||
})
|
||||
|
||||
mockActivities.takeScreenshotsActivity.mockResolvedValue([
|
||||
{ key: 'file/asset-video/screenshots/shot1.webp', timestamp: 0.0 },
|
||||
{ key: 'file/asset-video/screenshots/shot2.webp', timestamp: 5.0 },
|
||||
{ key: 'files/asset-video/screenshots/shot1.webp', timestamp: 0.0 },
|
||||
{ key: 'files/asset-video/screenshots/shot2.webp', timestamp: 5.0 },
|
||||
])
|
||||
|
||||
await transcodeMedia(task)
|
||||
@@ -295,8 +295,8 @@ describe('Transcode Workflow', () => {
|
||||
status: WorkflowTaskStatus.completed,
|
||||
output: {
|
||||
screenshots: [
|
||||
{ key: 'file/asset-video/screenshots/shot1.webp', timestamp: 0.0 },
|
||||
{ key: 'file/asset-video/screenshots/shot2.webp', timestamp: 5.0 },
|
||||
{ key: 'files/asset-video/screenshots/shot1.webp', timestamp: 0.0 },
|
||||
{ key: 'files/asset-video/screenshots/shot2.webp', timestamp: 5.0 },
|
||||
],
|
||||
},
|
||||
})
|
||||
@@ -336,7 +336,7 @@ describe('Transcode Workflow', () => {
|
||||
})
|
||||
|
||||
mockActivities.overlayAnnotationsActivity.mockResolvedValue(
|
||||
'file/asset-image/annotations/ann1.webp',
|
||||
'files/asset-image/annotations/ann1.webp',
|
||||
)
|
||||
|
||||
await transcodeMedia(task)
|
||||
@@ -350,7 +350,7 @@ describe('Transcode Workflow', () => {
|
||||
expect(mockActivities.updateTaskStatusActivity).toHaveBeenCalledWith({
|
||||
taskId: 'task-image-ann',
|
||||
status: WorkflowTaskStatus.completed,
|
||||
output: { key: 'file/asset-image/annotations/ann1.webp' },
|
||||
output: { key: 'files/asset-image/annotations/ann1.webp' },
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user