Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/worker/src/modules/buckets/getObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ export class GetObject extends OpenAPIRoute {
object.writeHttpMetadata(headers);
headers.set("etag", object.httpEtag);
headers.set("content-length", object.size.toString());

const fileName = filePath.split("/").pop() || "download";
const asciiFileName = fileName
.replace(/[^\x20-\x7E]/g, "_")
.replace(/"/g, "'");
headers.set(
"Content-Disposition",
`attachment; filename="${filePath.split("/").pop()}"`,
`attachment; filename="${asciiFileName}"; filename*=UTF-8''${encodeURIComponent(fileName)}`,
);

return new Response(object.body, {
Expand Down
Loading