I'm getting an OutOfMemoryError exception while reading image file from disk folder. What I do:
@GetMapping(value = "/user/image")
public ResponseEntity<byte[]> identificationImage(@RequestParam String path, @RequestParam String filename) {
byte[] image = Files.readAllBytes(Paths.get(path, filename));
return ResponseEntity.ok().contentType(MediaType.IMAGE_JPEG).body(image);
}
Is there a way to read files without loading into memory or something?
Out of memory error in a spring boot + spring data web application.