title: Spring Boot - Writing media (image, mp3, mp4) file to response output stream
body: <p>I am new to Servlets and Spring Framework. 
  I try to get media files from directory through Rest Service.</p>
  
  <p>For videos/mp4 I couldn't find anything.</p>
  
  <p>For audio I did this:
  <a href="https://stackoverflow.com/questions/12454484/writing-mp3-file-to-response-output-stream">Writing mp3 file to response output stream</a></p>
  
  <p>For images I did this:</p>
  
  <pre><code>@RequestMapping("/tmp/{uuid}")
  @ResponseBody
  public ResponseEntity&lt;InputStreamResource&gt; getTmp(@PathVariable("uuid") String uuid)
          throws IOException {
  
      Path path = Paths.get("/media/psmaster/HDD/TUC-IPS/" + uuid);
      String contentType = Files.probeContentType(path);
      FileSystemResource file = new FileSystemResource("/media/psmaster/HDD/TUC-IPS/" + uuid);
      return ResponseEntity
              .ok()
              .contentLength(file.contentLength())
              .contentType(
                      MediaType.parseMediaType(contentType))
              .body(new InputStreamResource(file.getInputStream()));
  }
  </code></pre>
  
  <p>Can someone please help to figure out the problem?</p>