Pass content-disposition header through file proxy
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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"`)
|
||||
})
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user