Saving zip file on client-side that was streamed from server
alexminnaar opened this issue · 1 comments
alexminnaar commented
Hello, sort of a beginner here. I am zipping a few files from S3 on the server side using the Express framework like this
router.get('/download', function (req, res, next) {
const region = 'us-west-2';
const bucket = 'my-bucket';
const folder = 'my-folder/';
const file1 = '1.jpg';
const file2 = '2.jpg';
const file3 = '3.jpg';
s3Zip
.archive({ region: region, bucket: bucket}, folder, [file1, file2, file3])
.pipe(res)
});
and I think that part is working correctly because I am getting a response on the client side that looks like this (from the chrome console)
But my goal here is to download the zip file to the client's browser. I am using Angular File Saver to do this. I have tried
var blob = new Blob([res._body], {type: "application/zip"});
FileSaver.saveAs(blob, "test-new.zip");
where res
is the response corresponding to the above image. A zip file does download but when I try to open it I get the following error
Can anyone see why this is happening?
alexminnaar commented
ah it looks like I just needed to add {responseType: ResponseContentType.Blob }
to the request