SpringBootインタフェースは画像を返します
859 ワード
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity getFile(@RequestParam long id) {
Result result = fileService.getFile(id);
if (result.getCode() == 1) {
MediaType mediaType = MediaType.parseMediaType(result.getMsg());
HttpHeaders headers = new HttpHeaders();
headers.setContentType(mediaType);
ResponseEntity e = new ResponseEntity(result.getData(), headers, HttpStatus.OK);
return e;
}
return ResponseEntity.status(404).body(result.getMsg());
}
@RequestMapping(method = RequestMethod.GET, produces = "image/png")