Have looked at all the tutorials on how to download files from S3 to local disk. I have followed all the solutions and what they do is download the file to the server and not to the client. The code I currently have is
app.get('/download_file', function(req, res) {
var file = fs.createWriteStream('/Users/arthurlecalvez/Downloads/file.csv');
file.on('close', function(){console.log('done'); });
s3.getObject({ Bucket: 'data.pool.al14835', Key: req.query.filename }).on('error', function (err) {
console.log(err);
}).on('httpData', function (chunk) {
file.write(chunk);
}).on('httpDone', function () {
file.end();
}).send();
res.send('success')
})
How do I then send this to the client so that it is downloaded onto their device?