I am trying to download a file from S3 directly in browser. I am using AWS Javascript SDK alongwith NodeJS + Webpack.
I am able to make a GetObject request and can see the browser (Chrome) downloading the bytes in "Developer tools" view.
I have "Content Disposition " header in response set as:
Content-Disposition:attachment; filename="A1.jpeg" However I do not see "Save As" dialog or any file being created in my filesystem (in Downloads folder). Where are the bytes going to?
How can I save the data in a file ?
Here's my code :
var getObject = function getObject(bucketName, fileName) { var params = { Bucket: bucketName, Key: fileName, ResponseContentDisposition: 'attachment; filename="' + fileName + '"' }; return s3.getObject(params).promise(); } getObject(BUCKET_NAME, item) .then( function (getFileResponse) { console.log(" file downloaded.. " ); } , function(error) { // Common error handling console.log(" error = " + error); })