title: download a file from Spring boot rest service
body: <p>I am trying to download a file from a Spring boot rest service.</p>
  
  <pre><code>@RequestMapping(path="/downloadFile",method=RequestMethod.GET)
      @Consumes(MediaType.APPLICATION_JSON_VALUE)
      public  ResponseEntity&lt;InputStreamReader&gt; downloadDocument(
                  String acquistionId,
                  String fileType,
                  Integer expressVfId) throws IOException {
          File file2Upload = new File("C:\\Users\\admin\\Desktop\\bkp\\1.rtf");
          HttpHeaders headers = new HttpHeaders();
          headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
          headers.add("Pragma", "no-cache");
          headers.add("Expires", "0");
          InputStreamReader i = new InputStreamReader(new FileInputStream(file2Upload));
          System.out.println("The length of the file is : "+file2Upload.length());
  
          return ResponseEntity.ok().headers(headers).contentLength(file2Upload.length())
                  .contentType(MediaType.parseMediaType("application/octet-stream"))
                  .body(i);
          }
  </code></pre>
  
  <p>When I tried to download the file from the browser, it starts the download, but always fails. Is there anything wrong with the service which is causing the download to fail?</p>