title: Angular doesn't download a file from a stream ( StreamingResponseBody )
body: <p>I'm using angular to download big files, for the backend I'm using spring boot, here's the code of the end point:</p>
  
  <pre><code>@RequestMapping(value = "/download", method = RequestMethod.GET)
  public StreamingResponseBody download(@PathVariable String path) throws IOException {
  
      final InputStream file =azureDataLakeStoreService.readFile(path);
      return (os) -&gt; {
          readAndWrite(file , os);
      };
  }
  
  private void readAndWrite(final InputStream is, OutputStream os)
          throws IOException {
      byte[] data = new byte[2048];
      int read = 0;
      while ((read = is.read(data)) &gt;= 0) {
          System.out.println("appending to file");
          os.write(data, 0, read);
      }
      os.flush();
  }
  </code></pre>
  
  <p>When I try to get the file using curl it works, and I can see the file being downloaded and it's size increasing:</p>
  
  <pre><code>curl -H "Authorization: Bearer &lt;MyToken&gt;" http://localhost:9001/rest/api/analyses/download --output test.zip
  </code></pre>
  
  <p>However, when I try to download a file using angular it doesn't work, even though the request is successful, and I can see in the logs the text "appending to file" showing multiple times, but nothing is downloading on the browser, here's my code:</p>
  
  <pre><code>this.http.get(url, { headers: headers, responseType: 'blob', observe: 'response' })
      .subscribe(response =&gt; {
          const contentDispositionHeader: string = response.headers.get('Content-Disposition');
          const parts: string[] = contentDispositionHeader.split(';');
          const filename = parts[1].split('=')[1];
          const blob = new Blob([response.body], {
              type: 'application/zip'
          });
          saveAs(blob, filename);
      });
  </code></pre>
  
  <p>saveAs() belong to <a href="https://github.com/Infinidat/file-saver" rel="nofollow noreferrer">file-saver</a>, btw the above code works when I try to download a file as a byte[] ( without streaming ).</p>
  
  <p>All I can find in the internet is this <a href="https://gist.github.com/bmchild/48edfe5f46005518883ea6d2b2d15eda" rel="nofollow noreferrer">code</a> and it's using angularJs while I'm using angular 5, Can anybody point the problem! thanks.</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>I can see that the file is being downloaded in the network tab of Google chrome, but I have no idea where the file is being saved.</p>
  
  <p><a href="https://i.stack.imgur.com/wPTCj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wPTCj.png" alt="enter image description here"></a></p>