perf(turntable): stream file via Bun.file and increase upload timeout

This commit is contained in:
yiling
2026-10-08 23:20:44 +08:00
parent 06ea4eed78
commit e06409690a
+2 -3
View File
@@ -260,7 +260,6 @@ export class TurntableService {
throw new Error('Turntable renderer URL is not configured.') throw new Error('Turntable renderer URL is not configured.')
} }
const fileBytes = fs.readFileSync(filePath)
const headers: Record<string, string> = { const headers: Record<string, string> = {
'content-type': 'application/octet-stream', 'content-type': 'application/octet-stream',
'x-filename': encodeURIComponent(filename), 'x-filename': encodeURIComponent(filename),
@@ -273,8 +272,8 @@ export class TurntableService {
const response = await fetch(`${config.url}/v1/files`, { const response = await fetch(`${config.url}/v1/files`, {
method: 'POST', method: 'POST',
headers, headers,
body: fileBytes, body: Bun.file(filePath),
signal: AbortSignal.timeout(120000), signal: AbortSignal.timeout(300000),
}) })
if (!response.ok) { if (!response.ok) {