I am trying to get downloading files from S3 via node/knox working. My javascript call is working and successfully downloads the file, but I want to download it as an attachment. I have tried setting the headers to 'Content-disposition': 'attachment; filename=myfile.zip'
, but it doesn't seem to be working. Here is my sample code:
var mimetype = mime.lookup(product.filename);
var headers = {
'Content-disposition': 'attachment; filename=' + product.filename,
'Content-type': mimetype
};
var get = knox.getFile(product.filename, function(err, result){
if(err) { return next(err); }
res.setHeader('Content-disposition', 'attachment; filename=' + product.filename);
res.setHeader('Content-type', mimetype);
result.pipe(res);
});
I have also tried setting those headers on the knox call, but still won't download as attachment.