mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-05 23:54:25 +00:00
fix(s3): address code review feedback on security and memory efficiency
This commit is contained in:
@@ -11,7 +11,8 @@ const route = new Hono()
|
|||||||
onFound: (_path, c) => {
|
onFound: (_path, c) => {
|
||||||
const filename = c.req.query('filename')
|
const filename = c.req.query('filename')
|
||||||
if (filename) {
|
if (filename) {
|
||||||
c.header('Content-Disposition', `attachment; filename="${filename}"`)
|
const safeFilename = filename.replace(/["\r\n]/g, '_')
|
||||||
|
c.header('Content-Disposition', `attachment; filename="${safeFilename}"`)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -199,8 +199,7 @@ export class S3StorageService implements S3Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async uploadFileToKey(filePath: string, key: string, contentType: string): Promise<void> {
|
async uploadFileToKey(filePath: string, key: string, contentType: string): Promise<void> {
|
||||||
const fileContent = readFileSync(filePath)
|
await this.client.write(key, Bun.file(filePath), {
|
||||||
await this.client.write(key, fileContent, {
|
|
||||||
bucket: this.bucket,
|
bucket: this.bucket,
|
||||||
type: contentType,
|
type: contentType,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user