on 04-05-2021 11:23 AM
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?
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");
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.