兴安优化提交
This commit is contained in:
@@ -294,10 +294,54 @@ public class SysFileController
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
// initFlowRules();
|
||||
// //上传前进行人脸检测
|
||||
// String imgBase64 = MinioUtil.getBase64String(file);
|
||||
// checkPhoto(imgBase64);
|
||||
initFlowRules();
|
||||
//上传前进行人脸检测
|
||||
String imgBase64 = MinioUtil.getBase64String(file);
|
||||
checkPhoto(imgBase64);
|
||||
|
||||
// 上传并返回访问地址
|
||||
String fileNames = FileUploadUtils.uploadMinio(file, this.bucketName1, fileName);
|
||||
SysFile sysFile = new SysFile();
|
||||
sysFile.setName(FileUtils.getName(fileNames));
|
||||
fileNames = fileNames.replace(miniourl, miniogwurl);
|
||||
sysFile.setUrl(fileNames);
|
||||
return R.ok(sysFile);
|
||||
} catch (Exception e) {
|
||||
log.error("上传文件失败", e);
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件非证件照上传请求
|
||||
*/
|
||||
@PostMapping("uploadMinio3")
|
||||
public R<SysFile> uploadMinio3(MultipartFile file, String fileName) {
|
||||
try {
|
||||
//判断压缩图片
|
||||
if ((1024 * 1024 * 0.1) <= file.getSize()) {
|
||||
// 小于 1M 的
|
||||
try {
|
||||
String fileNames1 = file.getOriginalFilename();
|
||||
File newFile = new File(fileNames1);
|
||||
if ((1024 * 1024 * 0.1) <= file.getSize() && file.getSize() <= (1024 * 1024)) {
|
||||
Thumbnails.of(file.getInputStream()).scale(1f).outputQuality(0.4f).toFile(newFile);
|
||||
}
|
||||
// 1 - 2M 的
|
||||
else if ((1024 * 1024) < file.getSize() && file.getSize() <= (1024 * 1024 * 2)) {
|
||||
Thumbnails.of(file.getInputStream()).scale(1f).outputQuality(0.2f).toFile(newFile);
|
||||
}
|
||||
// 2M 以上的
|
||||
else if ((1024 * 1024 * 2) < file.getSize()) {
|
||||
Thumbnails.of(file.getInputStream()).scale(1f).outputQuality(0.1f).toFile(newFile);
|
||||
}
|
||||
// 转为 MultipartFile
|
||||
file = PictureUtils.getMultipartFile(newFile);
|
||||
newFile.delete();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// 上传并返回访问地址
|
||||
String fileNames = FileUploadUtils.uploadMinio(file, this.bucketName1, fileName);
|
||||
|
||||
Reference in New Issue
Block a user