refactored storage, style tweaks
Co-authored-by: timvisee <tim@visee.me>
This commit is contained in:
parent
abc58518ea
commit
e909a3bae8
6 changed files with 26 additions and 71 deletions
|
@ -7,6 +7,7 @@ module.exports = async function(req, res) {
|
|||
const id = req.params.id;
|
||||
try {
|
||||
const meta = req.meta;
|
||||
const contentLength = await storage.length(id);
|
||||
const fileStream = await storage.get(id);
|
||||
let cancelled = false;
|
||||
|
||||
|
@ -15,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