I found this article which properly explains a working way (I tested it) of 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) {
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?
It is not possible to zip the files in SAPUI5. The reason is that the JSUtils library doesn't work as expected in SAPUI5. I believe that the main reason for this is that it is Promise based.
Note: Promises doesn't work on an oData service in SAPUI5 because it only accepts batch calls or async.