How to download multiple files from S3 and download as a zip file

Hi there! We don't have a native solution for this, but you should be able to add an external library to solve for this.

In this example, I'm using this external library: https://cdnjs.cloudflare.com/ajax/libs/jszip/3.7.1/jszip.min.js

Then, I have a JS query that runs the following, where query3 and query5 are S3 read queries:

var zip = new JSZip();

var img = zip.folder("images");

img.file(query3.data.Key, query3.data.Body, {base64: true});

img.file(query5.data.Key, query5.data.Body, {base64: true});

zip.generateAsync({type:"base64"}).then(function (base64) {

utils.downloadFile({base64Binary: base64}, "images", "zip")

}, function (err) {

utils.showNotification({title: "Error", description: err, notificationType: "Error"})

});

2 Likes