1@RequestMapping(value = "api/images")
2public class ImageController {
3
4 @Autowired
5 public ImageService imageService;
6 @PostMapping(value ="upload")
7 public ResponseEntity uploadImage(@RequestParam MultipartFile file){
8 return this.imageService.uploadToLocalFileSystem(file);
9 }
10 @GetMapping(
11 value = "getImage/{imageName:.+}",
12 produces = {MediaType.IMAGE_JPEG_VALUE,MediaType.IMAGE_GIF_VALUE,MediaType.IMAGE_PNG_VALUE}
13 )
14 public @ResponseBody byte[] getImageWithMediaType(@PathVariable(name = "imageName") String fileName) throws IOException {
15 return this.imageService.getImageWithMediaType(fileName);
16 }
17}
18