fix(s3): conform to RFC 6266 for ResponseContentDisposition filename encoding

This commit is contained in:
saltbo
2026-05-27 14:12:15 -04:00
parent 60b4dbf004
commit 399f9325a5
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -185,7 +185,7 @@ describe('S3Service', () => {
expect.anything(),
expect.objectContaining({
input: expect.objectContaining({
ResponseContentDisposition: 'attachment; filename="my%20photo.jpg"',
ResponseContentDisposition: 'attachment; filename="my photo.jpg"; filename*=UTF-8\'\'my%20photo.jpg',
}),
}),
expect.anything(),
+1 -1
View File
@@ -57,7 +57,7 @@ export class S3Service {
const command = new GetObjectCommand({
Bucket: storage.bucket,
Key: key,
ResponseContentDisposition: `attachment; filename="${encodeURIComponent(filename)}"`,
ResponseContentDisposition: `attachment; filename="${filename.replace(/"/g, '\\"')}"; filename*=UTF-8''${encodeURIComponent(filename)}`,
})
const url = await getSignedUrl(client, command, { expiresIn })
return this.applyCustomHost(storage, url)