mirror of
https://github.com/timvisee/send.git
synced 2025-10-05 10:29:26 +02:00
refactored storage, style tweaks
This commit is contained in:
parent
8fb770a4ea
commit
55df061567
8 changed files with 42 additions and 30 deletions
|
@ -7,9 +7,7 @@ module.exports = async function(req, res) {
|
|||
const id = req.params.id;
|
||||
try {
|
||||
const meta = req.meta;
|
||||
if (meta.dead || meta.flagged) {
|
||||
return res.sendStatus(404);
|
||||
}
|
||||
const contentLength = await storage.length(id);
|
||||
const fileStream = await storage.get(id);
|
||||
let cancelled = false;
|
||||
|
||||
|
@ -18,6 +16,10 @@ module.exports = async function(req, res) {
|
|||
fileStream.destroy();
|
||||
});
|
||||
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'application/octet-stream',
|
||||
'Content-Length': contentLength
|
||||
});
|
||||
fileStream.pipe(res).on('finish', async () => {
|
||||
if (cancelled) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue