1

I want to send file from node.js server to client on Angular. I'm using fileSaver.js on client.

Server:

res.download('123.txt', function(err){
    if(err){
        console.log('error');
    }
})

Cliet:

$http.post('/downloadFile').success(function(res){
   var file = new Blob([res]);
   saveAs(file, '123.txt');
}

But it works only with .txt files. How to do this with other formats?

br.julien
  • 3,420
  • 2
  • 23
  • 44
KIKIMIKI
  • 11
  • 3

1 Answers1

0

check this: Failed to load PDF document - Angular JS - BLOB

set responseType:

$http.post('/downloadFile','', {responseType:'arraybuffer'}).success(function(res){.....}
Community
  • 1
  • 1
Reza Afzalan
  • 5,646
  • 3
  • 26
  • 44