记得上下班打卡 | git大法好,push需谨慎

Commit 90b6b426 authored by 胡佳晨's avatar 胡佳晨

Merge branch 'bug_upload_pic' into pre

parents 662ee554 f6079026
......@@ -101,7 +101,53 @@ public class AlOssController {
try {
if (null == ossFile || (isCutFrame > 0 && ossFile.getVideoImg().isEmpty())) { //保证上传过的文件也能截帧
// 上传
ossFile = this.uploadOssFile(file, pathName, buckType, resize, fileNew, isCutFrame);
ossFile = this.uploadOssFile(file, pathName, buckType, resize, fileNew, isCutFrame, true);
}
} finally {
// 删除临时文件 因为老文件也生成了所以也要删除
FilesUtils.deleteTempFile(fileNew);
}
if (null == ossFile) {
return ResponseDto.failure("上传失败,该文件不合规,请勿上传带有联系方式、色情、涉政、广告等敏感文件");
} else {
BeanUtils.copyProperties(ossFile, uploadVo);
return ResponseDto.success(uploadVo);
}
}
@PostMapping("/upload/unsm")
@ApiOperation("阿里云上传-不鉴黄")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", dataType = "File", name = "file", value = "文件", required = true),
@ApiImplicitParam(type = "form", dataType = "String", name = "pathName", value = "归类的文件夹名称 比如banner上传就传 banner 返回的地址就会是bnanner/XXX", defaultValue = "test"),
@ApiImplicitParam(type = "form", dataType = "Integer", name = "buckType", value = "buckType 1正常的任何文件上传 2apk上传", defaultValue = "1"),
@ApiImplicitParam(type = "form", dataType = "Integer", name = "resize", value = "resize", defaultValue = "0"),
@ApiImplicitParam(type = "form", dataType = "Integer", name = "isCutFrame", value = "是否截取帧数 用于视频获取图片 0不需要 1需要", defaultValue = "0"),
})
public ResponseDto<UploadVo> uploadUnSm(
@RequestParam MultipartFile file,
@RequestParam(defaultValue = "other") String pathName,
@RequestParam(defaultValue = "1", required = false) int buckType,
@RequestParam(defaultValue = "0", required = false) int resize,
@RequestParam(defaultValue = "0", required = false) int isCutFrame
) {
if (file.equals("") || file.getSize() <= 0) {
return ResponseDto.failure("不能上传大小为0的文件");
}
File fileNew = FilesUtils.multipartFileToFile(file);
if (null == fileNew) {
return ResponseDto.failure("multipartFileToFile Error");
}
// 是否上传过 有直接返回
PlatformOssFiles ossFile = this.getOldOssFile(fileNew);
UploadVo uploadVo = new UploadVo();
try {
if (null == ossFile || (isCutFrame > 0 && ossFile.getVideoImg().isEmpty())) { //保证上传过的文件也能截帧
// 上传
ossFile = this.uploadOssFile(file, pathName, buckType, resize, fileNew, isCutFrame, false);
}
} finally {
// 删除临时文件 因为老文件也生成了所以也要删除
......@@ -146,7 +192,7 @@ public class AlOssController {
* @param fileNew
* @return
*/
private PlatformOssFiles uploadOssFile(MultipartFile file, String pathName, int buckType, int resize, File fileNew, int isCutFrame) {
private PlatformOssFiles uploadOssFile(MultipartFile file, String pathName, int buckType, int resize, File fileNew, int isCutFrame, Boolean isShuMei) {
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
int size = 0;
String filename, contentType, uploadPath = "";
......@@ -167,10 +213,12 @@ public class AlOssController {
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, uploadPath, fileNew);
ossClient.putObject(putObjectRequest);
if (contentType.contains("image") && !contentType.equals("image/vnd.adobe.photoshop")) {
if (!shumeiUtil.checkImage(IDGenerator.nextSnowId(), imgUrl.concat(uploadPath))) {
ossClient.deleteObject(bucketName, uploadPath);
return null;
if (isShuMei) {
if (contentType.contains("image") && !contentType.equals("image/vnd.adobe.photoshop")) {
if (!shumeiUtil.checkImage(IDGenerator.nextSnowId(), imgUrl.concat(uploadPath))) {
ossClient.deleteObject(bucketName, uploadPath);
return null;
}
}
}
......@@ -238,7 +286,7 @@ public class AlOssController {
private PlatformOssFiles ossFileCutFrame(String ossFileUrl, String pathName, int buckType) {
String style = "?x-oss-process=video/snapshot,t_0,f_jpg,w_0,h_0,m_fast,ar_auto";
File fileNew = FilesUtils.inputStreamToFile(imgUrl.concat(ossFileUrl).concat(style), System.currentTimeMillis() + ".jpg");
return this.uploadOssFile(null, pathName, buckType, 0, fileNew, 0);
return this.uploadOssFile(null, pathName, buckType, 0, fileNew, 0,false);
}
@PostMapping("/uploadUrl")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment