fox-send/server/routes/download.js

16 lines
358 B
JavaScript
Raw Normal View History

const storage = require('../storage');
module.exports = async function(req, res) {
const id = req.params.id;
try {
2020-07-27 18:18:52 +00:00
const { length, stream } = await storage.get(id);
2020-07-25 18:22:57 +00:00
res.writeHead(200, {
'Content-Type': 'application/octet-stream',
2020-07-27 18:18:52 +00:00
'Content-Length': length
});
2020-07-27 18:18:52 +00:00
stream.pipe(res);
} catch (e) {
res.sendStatus(404);
}
};