-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Not tested on UNIX, but on Windows 8.1 /download returns a file named 'download'.
By adding correct headers I download a more comprehensible file : 'd411b07f-ef8c-437d-910e-b4b48db8e878.mp4'
download: function (req, res) {
var path = '.tmp\\uploads\\'+req.param('path');
console.log(path);
var mime = require('mime');
var mimetype = mime.lookup(path);
res.setHeader('Content-disposition', 'attachment; filename=' + path);
res.setHeader('Content-type', mimetype);
require('fs').createReadStream(path)
.on('error', function (err) {
return res.serverError(err);
})
.pipe(res);
}
};
Edit : removing "Content-disposition" streams the file to the browser.
Metadata
Metadata
Assignees
Labels
No labels