title: Files downloaded with Angular 2 over Spring REST API are twice size. Why?
body: <p>I want to download files from angular 2. My problem is, that all files I get from the Spring REST API are twice file size.</p>
  
  <p>Angular Snippet:</p>
  
  <pre><code>return this.authHttp.get(this.restAPI + '/downloadFile/' + fileId)
           .toPromise()
               .then(response =&gt; {
                  //  var arrayBufferView = new Uint8Array( response.arrayBuffer() );
                  //  var blob = new Blob( [ arrayBufferView ], { type: response.headers.get("Content-Type") } );
                  //  return blob;
  
                   return new Blob([response.arrayBuffer()], { type: response.headers.get("Content-Type")})
                  })
  
              .catch(this.handleError);
  </code></pre>
  
  <p>Spring REST Snippet:</p>
  
  <pre><code>@RequestMapping(value = "/downloadFile2/{fileId}",
          method = RequestMethod.GET)
  public void downloadFileHandler2(@RequestHeader("Authorization") String token, 
          @PathVariable String fileId, HttpServletResponse response) throws IOException {
  
      changeToCustomerDataBase(token);
  
      File file = projectService.readFromDB(fileId);
  
      response.addHeader("Content-Disposition", "attachment; filename="+file.getName());
      response.setContentType(Files.probeContentType(file.toPath()));
      response.setContentLengthLong(file.length());
  
      FileInputStream fis = new FileInputStream(file);
      int c; 
      while((c = fis.read()) &gt; -1) {
          response.getOutputStream().write(c);    
      }
  
      response.flushBuffer();
  
      fis.close();
  }
  </code></pre>
  
  <p>Files, thar coming from the database, have the original size.</p>
  
  <p>What is wrong? Did I forget something? I'm very grateful for any help.</p>