I'm using spring boot to save some images to the db along with an order. I am able to return a single image at a time but I would like to return 2 or more images in the body. I tried using arrays or arrayLists but that didn't work. Is there a way to return multiple images ?
My code
@GetMapping(value = "/getOrder")
public ResponseEntity getOrder(@RequestParam Long input_id) {
try {
Optional<OrderItems> orderItemOptional = materialService.getOrder(input_id);
if (!orderItemOptional.isEmpty()) {
byte[] imageBytes = orderItemOptional.get().getEyewearImage().getImage();
return ResponseEntity.ok().contentType(MediaType.IMAGE_JPEG).body(imageBytes);
} else {
return ResponseEntity.badRequest().body("Bad request");
}
} catch (Exception e) {
LOGGER.warn(e.getMessage(), e);
return ResponseEntity.badRequest().body(e.getMessage());
}
}