title: How to display files in browser
body: <p>I am trying to display files (pdf, ms office files, txt) inside the browser using <code>&lt;iframe&gt;</code>. I am able to display txt and pdf files inside iframe, but unable to do the same for other files, open/Save dialog box appears instead of displaying them inside the iframe.<br>
  I have written the below code,</p>
  
  <pre><code> @RequestMapping(value="/getPreview",method=RequestMethod.GET)
  @ResponseBody
  public ResponseEntity&lt;byte[]&gt; getPreview(@RequestParam(value="file") String path) throws IOException{
  
       Path paths = Paths.get(path);
       byte[] data = Files.readAllBytes(paths);
       File file = new File(path);
       String name=file.getName();
       String mime=Files.probeContentType( Paths.get(path));
       HttpHeaders headers=new HttpHeaders();
       headers.setContentType(org.springframework.http.MediaType.parseMediaType(mime));
       headers.add("Content-Disposition", "inline;filename=" + name);
       headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
       ResponseEntity&lt;byte[]&gt; response = new ResponseEntity&lt;byte[]&gt;(data,headers, HttpStatus.OK);
  
       return response;
  
  }
  </code></pre>
  
  <p>Is there any more attributes that I should add to the response header to make the requirement work?<br><br>
  html:<code>&lt;iframe src="/getPreview?file=filePath" style="width: 400px; height: 400px;"&gt;&lt;/iframe&gt;</code></p>
  
  <p>Am using angualrjs as frontend.</p>