2017-08-24 21:54:02 +00:00
|
|
|
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
|
2017-08-24 21:54:02 +00:00
|
|
|
});
|
2020-07-27 18:18:52 +00:00
|
|
|
stream.pipe(res);
|
2017-08-24 21:54:02 +00:00
|
|
|
} catch (e) {
|
|
|
|
res.sendStatus(404);
|
|
|
|
}
|
|
|
|
};
|