Allow direct downloading of sequence reports.

If the `download` or `d` query parameter is supplied (even
without any value), the response will include a
`Content-Disposition: attachment` header. A filename will
also be suggested.
This commit is contained in:
D. Berge
2021-05-15 17:10:28 +02:00
parent c7e2e18cc8
commit b0f4559b83
5 changed files with 21 additions and 0 deletions

View File

@@ -13,6 +13,11 @@ const html = async function (req, res, next) {
const template = templates[0].template;
const response = await render(seis, template);
if ("download" in query || "d" in query) {
const filename = `${req.params.project}-seq${query.sequence.padStart(3, "0")}.html`;
res.set("Content-Disposition", `attachment; filename="${filename}"`);
}
res.status(200).send(response);
next();
} catch (err) {