Spring REST – returning image or a file

Just an example of how to return an image or a file from a rest controller. Idea can be to proxy image call or just to return a file. @GetMapping(value="/scans/{id}/{image}", produces = MediaType.IMAGE_JPEG_VALUE) public ResponseEntity<?> getScanImage(@PathVariable String id, @PathVariable String image) { final byte[] imageBytes = bucketApi.readScan(UUID.fromString(id), image); return new ResponseEntity<>(imageBytes, HttpStatus.OK); } @GetMapping(value="/scans/stream/{id}/{image}", produces … Continue reading Spring REST – returning image or a file