Pass content-disposition header through file proxy

This commit is contained in:
Cadence Ember
2026-07-16 15:01:50 +12:00
parent d4cd580555
commit 6cd36464fa
2 changed files with 7 additions and 1 deletions
+5
View File
@@ -98,6 +98,11 @@ as.router.get(`/download/matrix/:server_name/:media_id`, defineEventHandler(asyn
setResponseHeader(event, "Content-Type", contentType) setResponseHeader(event, "Content-Type", contentType)
setResponseHeader(event, "Transfer-Encoding", "chunked") setResponseHeader(event, "Transfer-Encoding", "chunked")
const contentDisposition = res.headers.get("content-disposition")
if (contentDisposition) {
setResponseHeader(event, "Content-Disposition", contentDisposition)
}
if (res.ok && query.success) { if (res.ok && query.success) {
return MEDIA_THUMBNAIL_PRESETS[query.data.preset](res.body) return MEDIA_THUMBNAIL_PRESETS[query.data.preset](res.body)
} else { } else {
+2 -1
View File
@@ -30,12 +30,13 @@ test("web download matrix: works if a known attachment", async t => {
api: { api: {
// @ts-ignore // @ts-ignore
async getMedia(mxc, init) { async getMedia(mxc, init) {
return new Response("", {status: 200, headers: {"content-type": "image/png"}}) return new Response("", {status: 200, headers: {"content-type": "image/png", "content-disposition": `attachment; filename="wa.png"`}})
} }
} }
}) })
t.equal(event.node.res.statusCode, 200) t.equal(event.node.res.statusCode, 200)
t.equal(event.node.res.getHeader("content-type"), "image/png") t.equal(event.node.res.getHeader("content-type"), "image/png")
t.equal(event.node.res.getHeader("content-disposition"), `attachment; filename="wa.png"`)
}) })
/** /**