I have requirement in my project with which when user select multiple file to download, we need to zip them and then make them to download. We have tested that the Struts2 action is listing all the file correctly and passing them to the UI. We've verified that the files are list on to UI correctly but when the blob statement executed, it made the zip file corrupted. Here is the my code snippet. Can anyone please help here?
Code:
$.ajax({
url: url,
data: data,
type: "POST",
async: true,
success: function (data) {
var binaryData = [];
binaryData.push(data);
var link=document.createElement('a');
link.href =window.URL.createObjectURL(**new Blob(binaryData, {type: "application/zip"**}));
link.download = "User Reports Data Files.zip"
link.click();
},
error: function (request, status, error) {
}
});