mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 20:17:14 +00:00
fix(s3): stream downloadToFile and putObject to prevent OOM on large files (#392)
* fix(s3): stream downloadToFile and putObject to prevent OOM on large files * fix(agent): preserve file MIME detection on download_asset and align local download directory creation
This commit is contained in:
@@ -39,10 +39,10 @@ export const localUploadRoute = new Hono().put(
|
||||
if (!file) {
|
||||
return c.text('No file uploaded', 400)
|
||||
}
|
||||
const buffer = Buffer.from(await file.arrayBuffer())
|
||||
const size = file.size
|
||||
finalContentType = file.type || 'application/octet-stream'
|
||||
await s3Service.putObject(bucket, key, buffer, size, finalContentType)
|
||||
const payload =
|
||||
typeof file.stream === 'function' ? file.stream() : Buffer.from(await file.arrayBuffer())
|
||||
await s3Service.putObject(bucket, key, payload, file.size, finalContentType)
|
||||
} else {
|
||||
const body = c.req.raw.body ?? (await c.req.arrayBuffer())
|
||||
await s3Service.putObject(bucket, key, body, contentLength, finalContentType)
|
||||
|
||||
Reference in New Issue
Block a user