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