SpringBlade 本地图片上传 生成缩略图
完整版:https://www.cnblogs.com/guxingy/p/13716463.html
核心代码
/**
* 上传文件
*/
@PostMapping("/upload")
@ApiOperationSupport(order = 8)
@ApiOperation(value = "上传文件", notes = "上传文件")
public R upload(MultipartFile file) throws IOException {
BladeFile bf = getFile(file);
bf.transfer(false);
// 生成缩略图
BufferedImage src =ImageUtil.readImage(bf.getUploadPath());
FileOutputStream output = new FileOutputStream("d://1.png");
ImageUtil.zoomFixed(src, output, null, 800, 800, true, null);
org.springblade.core.oss.model.BladeFile bladeFile = new org.springblade.core.oss.model.BladeFile();
bladeFile.setOriginalName(bf.getOriginalFileName());
bladeFile.setName(bf.getFileName());
bladeFile.setLink(SystemConstant.me().getDomain() + bf.getUploadVirtualPath());
return R.data(bladeFile);
}