I have this controller:
@GetMapping(value = "videos/{id}/{name}")
@ResponseBody
public final ResponseEntity<InputStreamResource>
retrieveResource(@PathVariable(value = "id") final String id,
@PathVariable(value = "name") final String name) throws Exception {
File initialFile = new File(id + name);
InputStream targetStream = new FileInputStream(initialFile);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.valueOf("video/mp4"));
headers.set("Accept-Ranges", "bytes");
headers.set("Expires", "0");
headers.set("Cache-Control", "no-cache, no-store");
headers.set("Connection", "keep-alive");
headers.set("Content-Transfer-Encoding", "binary");
return new ResponseEntity<>(new InputStreamResource(targetStream), headers, HttpStatus.OK);
}
when I access using the browser http://localhost:7080/videos/2/3
I see the video, but not when I put it in a HTML page:
<div class="media-box foto">
<video width="320" height="240" controls>
<video url="http://localhost:7080/videos/2/3" type="video/mp4">
</video>
</div>