给文件上传接口增加判断,防止上传分类错误

This commit is contained in:
jishenghua
2024-09-24 00:12:22 +08:00
parent 8bbf79c613
commit 6a05b9f6e3

View File

@@ -129,19 +129,24 @@ public class SystemConfigController {
try { try {
String savePath = ""; String savePath = "";
String bizPath = request.getParameter("biz"); String bizPath = request.getParameter("biz");
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; if ("bill".equals(bizPath) || "financial".equals(bizPath) || "material".equals(bizPath)) {
MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
if(fileUploadType == 1) { MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象
savePath = systemConfigService.uploadLocal(file, bizPath, request); if(fileUploadType == 1) {
} else if(fileUploadType == 2) { savePath = systemConfigService.uploadLocal(file, bizPath, request);
savePath = systemConfigService.uploadAliOss(file, bizPath, request); } else if(fileUploadType == 2) {
} savePath = systemConfigService.uploadAliOss(file, bizPath, request);
if(StringUtil.isNotEmpty(savePath)){ }
res.code = 200; if(StringUtil.isNotEmpty(savePath)){
res.data = savePath; res.code = 200;
}else { res.data = savePath;
res.code = 500; }else {
res.data = "上传失败!"; res.code = 500;
res.data = "上传失败!";
}
} else {
res.code = 505;
res.data = "文件分类错误!";
} }
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);