📅  最后修改于: 2022-03-11 14:52:03.096000             🧑  作者: Mango
@RequestMapping(value = "api/images")
public class ImageController {
@Autowired
public ImageService imageService;
@PostMapping(value ="upload")
public ResponseEntity uploadImage(@RequestParam MultipartFile file){
return this.imageService.uploadToLocalFileSystem(file);
}
@GetMapping(
value = "getImage/{imageName:.+}",
produces = {MediaType.IMAGE_JPEG_VALUE,MediaType.IMAGE_GIF_VALUE,MediaType.IMAGE_PNG_VALUE}
)
public @ResponseBody byte[] getImageWithMediaType(@PathVariable(name = "imageName") String fileName) throws IOException {
return this.imageService.getImageWithMediaType(fileName);
}
}