I want to force the browser to download a file from an external storage, given an url. I implemented this express controller post action:
var download = function(req, res) {
request(req.body.url).on('response', function(response) {
res.set({
'Content-Disposition': 'attachment; filename=' + req.body.filename,
'Content-Type': response.headers['content-type']
});
})
.pipe(res);
};
I don't know why the browser always receive a "inline" instead of "attachment", avoiding me to download the file.
In this case I use express and request, the server is hosted on Heroku and the server that hosts files is FilePicker.