标签:java,os,前端,bytes,new,上传,图片 From: https://www.cnblogs.com/Lee597/p/18205582
/**
* 查询对象
*/
@GetMapping("/getImage")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "上传图片", notes = "保存本地")
public R getImg(String jobId, HttpServletResponse response) throws IOException {
//region 上传图片给前端
File file = new File(supperMapper.selectImageAddr(jobId));
byte[] bytes = new byte[1024];
try (OutputStream os = response.getOutputStream();
FileInputStream fis = new FileInputStream(file)){
while((fis.read(bytes))!=-1){
os.write(bytes);
os.flush();;
}
}catch (IOException e){
log.info(e.getMessage());
}
return R.success("OK");
//endregion
}