feat(api,webui): implement image compression, auto-refresh for uploads, and infinite pagination for collections/shares

This commit is contained in:
yiling
2026-06-08 12:14:14 +08:00
parent 2ea7706d82
commit 688e1a4ede
12 changed files with 232 additions and 94 deletions
+4 -4
View File
@@ -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')