📅  最后修改于: 2022-03-11 14:58:37.003000             🧑  作者: Mango
import org.springframework.http.MediaType;
@GetMapping(value = "/file/image/{id}", produces = {MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_PNG_VALUE})
@ResponseBody
public byte[] image(@PathVariable String id){
byte[] data = null;
UploadFile file = mongoTemplate.findImageById(id, UploadFile.class);
if(file != null){
data = file.getContent().getData();
}
return data;
}