feat(api): Add real filename to proxy

This commit is contained in:
Jesse Wierzbinski 2024-06-05 18:07:22 -10:00
parent 7f4e39e08b
commit 908fdcaa79
No known key found for this signature in database

View file

@ -45,6 +45,11 @@ export default (app: Hono) =>
},
});
const realFilename =
media.headers
.get("Content-Disposition")
?.match(/filename="(.+)"/)?.[1] || id.split("/").pop();
return response(media.body, media.status, {
"Content-Type":
media.headers.get("Content-Type") ||
@ -52,6 +57,8 @@ export default (app: Hono) =>
"Content-Length": media.headers.get("Content-Length") || "0",
"Content-Security-Policy": "",
"Content-Encoding": "",
// Real filename
"Content-Disposition": `inline; filename="${realFilename}"`,
});
},
);