|
|
@@ -6,6 +6,7 @@ import com.fs.common.constant.Constants;
|
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.exception.file.OssException;
|
|
|
+import com.fs.common.utils.security.OssUploadSecurityUtils;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
@@ -229,8 +230,7 @@ public class CommonController
|
|
|
throw new OssException("上传文件不能为空");
|
|
|
}
|
|
|
// 上传文件
|
|
|
- String fileName = file.getOriginalFilename();
|
|
|
- String suffix = fileName.substring(fileName.lastIndexOf("."));
|
|
|
+ String suffix = OssUploadSecurityUtils.validateAndGetDotSuffix(file);
|
|
|
CloudStorageService storage = OSSFactory.build();
|
|
|
String url = storage.uploadSuffix(file.getBytes(), suffix);
|
|
|
return R.ok().put("url",url);
|
|
|
@@ -244,11 +244,11 @@ public class CommonController
|
|
|
throw new OssException("上传文件不能为空");
|
|
|
}
|
|
|
// 上传文件
|
|
|
- String fileName = file.getOriginalFilename();
|
|
|
- String suffix = fileName.substring(fileName.lastIndexOf("."));
|
|
|
- String prefix = fileName.substring(0, fileName.lastIndexOf("."));
|
|
|
+ String suffix = OssUploadSecurityUtils.validateAndGetDotSuffix(file);
|
|
|
+ // 禁止使用原始文件名构造 OSS 路径,避免路径穿越
|
|
|
CloudStorageService storage = OSSFactory.build();
|
|
|
- String url = storage.upload(file.getBytes(), prefix+System.currentTimeMillis()+suffix);
|
|
|
+ String url = storage.uploadSuffix(file.getBytes(), suffix);
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
return R.ok().put("url",url).put("fileName",fileName);
|
|
|
}
|
|
|
|
|
|
@@ -314,10 +314,9 @@ public class CommonController
|
|
|
throw new OssException("上传文件不能为空");
|
|
|
}
|
|
|
// 上传文件
|
|
|
- String fileName = file.getOriginalFilename();
|
|
|
- String suffix = fileName.substring(fileName.lastIndexOf("."));
|
|
|
- CloudStorageService storage = OSSFactory.build();
|
|
|
- String url = storage.uploadSuffix(file.getBytes(), suffix);
|
|
|
+ String suffix = OssUploadSecurityUtils.validateAndGetDotSuffix(file);
|
|
|
+ CloudStorageService storage = OSSFactory.build();
|
|
|
+ String url = storage.uploadSuffix(file.getBytes(), suffix);
|
|
|
vo.setErrno(0);
|
|
|
List<WangUploadVO.WangUploadItem> items=new ArrayList<>();
|
|
|
WangUploadVO.WangUploadItem item=new WangUploadVO.WangUploadItem();
|