pull request changes
This commit is contained in:
parent
83f0cd82a8
commit
ab86ecf90e
9
app.js
9
app.js
|
@ -26,12 +26,17 @@ app.get('/assets/download/:id', function(req, res) {
|
||||||
let id = req.params.id;
|
let id = req.params.id;
|
||||||
client.hget(id, "filename", function(err, reply) { // maybe some expiration logic too
|
client.hget(id, "filename", function(err, reply) { // maybe some expiration logic too
|
||||||
if (!reply) {
|
if (!reply) {
|
||||||
res.send('This link has expired!');
|
res.sendStatus(404);
|
||||||
} else {
|
} else {
|
||||||
res.setHeader('Content-Disposition', 'attachment; filename=' + reply);
|
res.setHeader('Content-Disposition', 'attachment; filename=' + reply);
|
||||||
res.setHeader('Content-Type', 'application/octet-stream');
|
res.setHeader('Content-Type', 'application/octet-stream');
|
||||||
|
|
||||||
|
res.download(__dirname + '/static/' + id, reply, function(err) {
|
||||||
|
if (!err) {
|
||||||
client.del(id);
|
client.del(id);
|
||||||
res.download(__dirname + '/static/' + id, reply);
|
fs.unlink(__dirname + '/static/' + id);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue