From 6cd36464fa686763fae442d7c9d761f45fcdb6d6 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Thu, 16 Jul 2026 15:01:50 +1200 Subject: [PATCH] Pass content-disposition header through file proxy --- src/web/routes/download-matrix.js | 5 +++++ src/web/routes/download-matrix.test.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/web/routes/download-matrix.js b/src/web/routes/download-matrix.js index 6d2772b..2664520 100644 --- a/src/web/routes/download-matrix.js +++ b/src/web/routes/download-matrix.js @@ -98,6 +98,11 @@ as.router.get(`/download/matrix/:server_name/:media_id`, defineEventHandler(asyn setResponseHeader(event, "Content-Type", contentType) setResponseHeader(event, "Transfer-Encoding", "chunked") + const contentDisposition = res.headers.get("content-disposition") + if (contentDisposition) { + setResponseHeader(event, "Content-Disposition", contentDisposition) + } + if (res.ok && query.success) { return MEDIA_THUMBNAIL_PRESETS[query.data.preset](res.body) } else { diff --git a/src/web/routes/download-matrix.test.js b/src/web/routes/download-matrix.test.js index 610a62d..2e76002 100644 --- a/src/web/routes/download-matrix.test.js +++ b/src/web/routes/download-matrix.test.js @@ -30,12 +30,13 @@ test("web download matrix: works if a known attachment", async t => { api: { // @ts-ignore 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.getHeader("content-type"), "image/png") + t.equal(event.node.res.getHeader("content-disposition"), `attachment; filename="wa.png"`) }) /**