feat(ccdi-project): 扩展文件上传支持CSV和PDF格式
- 修改文件类型校验逻辑,添加.csv和.pdf扩展名支持 - 实现大小写不敏感的文件扩展名校验(转为小写后判断) - 更新错误提示信息为"仅支持 PDF、CSV、Excel 文件"
This commit is contained in:
@@ -62,8 +62,10 @@ public class CcdiFileUploadController extends BaseController {
|
||||
return AjaxResult.error("文件 " + file.getOriginalFilename() + " 超过50MB限制");
|
||||
}
|
||||
String fileName = file.getOriginalFilename();
|
||||
if (!fileName.endsWith(".xlsx") && !fileName.endsWith(".xls")) {
|
||||
return AjaxResult.error("文件 " + fileName + " 格式不支持,仅支持Excel文件");
|
||||
String lowerFileName = fileName.toLowerCase();
|
||||
if (!lowerFileName.endsWith(".xlsx") && !lowerFileName.endsWith(".xls")
|
||||
&& !lowerFileName.endsWith(".csv") && !lowerFileName.endsWith(".pdf")) {
|
||||
return AjaxResult.error("文件 " + fileName + " 格式不支持,仅支持 PDF、CSV、Excel 文件");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user