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"`) }) /**