3

I need to download a file zip, created on my server, I have read several answers about this topic but my browser keeps downloading only 15 byte of the file zip. This is the callback function of the $http.post request

function(resp){
                          var blob = new Blob([resp], {type: "application/octet-stream", responseType: 'arraybuffer'})
                          console.log('response',resp)
                          FileSaver.saveAs(blob,'registrazioni.zip',(err) => {
                              console.log('saved success,error',err);
                          }

this is the request:

$http.post('/api/download/',data, {
          dataType : "binary",
          processData : false,
          responseType:'arraybuffer'})

thanks in advance

arpho
  • 1,576
  • 10
  • 37
  • 57

1 Answers1

0

Can you try the below code snippet, it worked for me.

var file = response.blob();

Then using the FileSaver make saveAs call:

file.then(function(file){
   saveAs(file, "registrazioni.zip");
});
Vijay
  • 1