/**
* 返回图片
* @param images
* @return
*/
@ApiOperation(value = "获取图片", httpMethod = "GET", notes = "获取图片")
@RequestMapping(value = "/getPhoto", produces = MediaType.IMAGE_JPEG_VALUE)
public byte[] getPhoto(@RequestParam(value = "images", required = true)String images) {
File file = new File(realPath);
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(file+"/"+images);
byte[] bytes = new byte[inputStream.available()];
inputStream.read(bytes, 0, inputStream.available());
return bytes;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
springboot项目返回图片
最新推荐文章于 2024-04-17 03:05:00 发布