Before anyone says “duplicate,” I just want to make sure people know that I have already addressed these issues:
1) Uses angular and php, not sure what is going on here (I don't know PHP): Download the zip file and run the "save file" dialog from the angular method
2) Unable to get this answer: how to download a zip file using angular
3) This person can already download, that has passed the point that I am trying to find out:
Download the external zip file from angular, caused by the action of the button
4) There is no answer for this:
download the .zip file from the server in nodejs
5) I don’t know what language it is in general:
https://stackoverflow.com/questions/35596764/zip-file-download-using-angularjs-directive
Given these questions , if this is still a duplicate, I apologize. Here is another version of this question.
My angular 1.5.X client gives me a list of names, of which each has an associated file. My Node 4.X / Express 4.X server accepts this list, gets the location of the files, creates a zip file using the express zip code from npm, and then sends this file back to the response. Then I want my client to initiate the browser setting "upload file".
Here is my client code (Angular 1.5.X):
function bulkdownload(titles){
titles = titles || [];
if ( titles.length > 0 ) {
$http.get('/query/bulkdownload',{
params:{titles:titles},
responseType:'arraybuffer'
})
.then(successCb,errorCb)
.catch(exceptionCb);
}
function successCb(response){
};
function errorCb(error){
alert('Error: ' + JSON.stringify(error));
};
function exceptionCb(ex){
alert('Exception: ' + JSON.stringify(ex));
};
};
Node (4.X) code with express mail, https://www.npmjs.com/package/express-zip :
router.get('/bulkdownload',function(req,resp){
var titles = req.query.titles || [];
if ( titles.length > 0 ){
utils.getFileLocations(titles).
then(function(files){
let filename = 'zipfile.zip';
resp.zip(files,filename,console.log);
},
_errorCb)
}
});
Here is my successCb in my client code (Angular 1.5.X):
function successCb(response){
var URL = $window.URL || $window.webkitURL || $window.mozURL || $window.msURL;
if ( URL ) {
var blob = new Blob([response.data],{type:'application/zip'});
var url = URL.createObjectURL(blob);
$window.open(url);
}
};
"blob", , . IE, . , blob - HTML5, " " . ? , ?
90% + IE11, angular PhantomJS (Karma) IE. , " " :
Exception: {"description":"Access is denied...<stack trace>}
, , .. !