title: StreamingResponseBody returning empty file
body: <p>I'm trying to create a rest service to download files from a repository, using Springboot. </p>
  
  <p>I'm trying to return a ResponseEntity with StreamingResponseBody, to return the file that i get from the repository, as an InputStream. </p>
  
  <p>This is the current code i have: </p>
  
  <pre class="lang-java prettyprint-override"><code>
  @GetMapping(path = "/downloadFile")
      public ResponseEntity&lt;StreamingResponseBody&gt; downloadFile(@RequestParam(value = "documentId") String documentId,
              HttpServletRequest request, HttpServletResponse response) throws InterruptedException, IOException {
  
          InputStream is = downloadService.getDocument(documentId);
  
          StreamingResponseBody out = outputStream -&gt; {
  
              outputStream.write(IOUtils.toByteArray(is));
          };
  
          HttpHeaders headers = new HttpHeaders();
          headers.add("Content-Type", "text/csv");
          headers.add("Content-Disposition", "attachment; filename=" + documentId);
          headers.add("Pragma", "no-cache");
          headers.add("Cache-Control", "no-cache");
  
          return (new ResponseEntity&lt;&gt;(out, headers, HttpStatus.OK));
  
      }
  </code></pre>
  
  <p>When I consume this endpoint, using directly the browser, or postman, the file that is downloaded comes empty. 
  I understand that the OutputStream is written to asynchronously (Async is enabled in the config class). </p>
  
  <p>How can I consume this service and get the file completely written, the way it comes from the repository I'm using ? ( if possible using Postman, just for testing purposes)</p>
  
  <p>Am i building the service correctly? </p>