cancel
Showing results for 
Search instead for 
Did you mean: 

How to zip all downloaded files in the browser

0 Kudos

Hello,

I found this article which properly explains a working way (I tested it), how to create a zip file of a "Hello.txt" file that the author creates with the function:

onPress: function(oControlEvent) {
   var zip = new JSZip();
   zip.file("Hello.txt", "Hello World\n"); //Here creates the file and the context
   zip.generateAsync({
      type: "blob"
   })
   .then(function(content) {
      // see FileSaver.js
      saveAs(content, "example.zip");
   });
},

I have the following function which successfully opens a new window and downloads all selected files:

downloadAttachments:function(){
  this.byId("UploadCollection").getSelectedItems().map(object => window.open(object.mProperties.url));},

How can I make the zip file contain all the downloads instead of the "Hello.txt" file?

View Entire Topic
I039810
Advisor
Advisor
0 Kudos

Hi

It is possible to download the files in a Zip format.

To achieve this , a service call has to be made and the list of files in the request has to be sent. Then, the service needs to zip the files together and send back the response.

Step 1: Adding a button to the UploadCollection’s Toolbar for downloading multiple files in a zip

<Button id="downloadZipButton"

text="Download ZIP"

press="onZipDownload"

enabled="false"

type="Transparent" />

Step 2: Defining the function for the ‘Download ZIP’ button to get the selected items for download

onZipDownload: function() {

var oUploadCollection = this.byId("UploadCollection");

var aSelectedItems = oUploadCollection.getSelectedItems();

if (aSelectedItems) {

// custom function to handle the download zip functionality

zipDownload(aSelectedItems);

} else {

MessageToast.show("Select items to download");

}

}