title: save zip file received in response body angular 2
body: <p>I have a rest service made with node.js and express.js, that returns a zip trough response using express-zip:</p>
  
  <pre><code>res.zip([{path:'file', name: 'file'}]);
  </code></pre>
  
  <p>When i call it with node, to test it, with the following code, it creates a valid zip file:</p>
  
  <pre><code>var fs = require('fs');
  var request = require('request');
  
  request({
      url: "http://deti-lei-2.ua.pt:3500/runProgram/posio/211/1",
      method: "GET",
      encoding: null,
      headers: {
          Authorization: 'token'
      }
  
  }).pipe(fs.createWriteStream('file.zip')).on('close', function () {
      console.log('File written!');
  });
  </code></pre>
  
  <p>But i need to use the service with angular 2, however, i tried many ways of doing the request and none worked, i always end up with a corrupt zip.
  One of the ways i tried was the following:</p>
  
  <pre><code>downloadFile(program: string) {
      var bytes = [];
      for(var i = 0 ; i &lt; program.length; i++){
          bytes.push(program.charCodeAt(i));
      }
          var FileSaver = require('file-saver');
          var blob = new Blob([bytes], {type:'application/zip'});
          FileSaver.saveAs(blob,'Program');
    }
  </code></pre>
  
  <p>I also tried creating a function in js with the code above, that was working, but i had no success because i could't use fs and request modules.
  I appreciate if someone can help.</p>