文件名限制。

This commit is contained in:
chenxudong 2024-12-06 14:15:30 +08:00
parent 4e2c53f64e
commit 2998a619a8
2 changed files with 5 additions and 2 deletions

View File

@ -155,7 +155,7 @@ public class EDDataServiceImpl implements EDDataService {
{
// 获取上级目录的名称
String fileName = edDataInfo.getDataName();
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), "文件名不符合规范,只能包含中文字符、下划线、连字符、加号、数字和英文字符");
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), "文件名不符合规范,只能包含中文字符、下划线、连字符、加号、数字和英文字符且长度小于32。");
Category categoryParent = new Category();
categoryParent.setCategoryId(edDataInfo.getCategoryId());
@ -318,7 +318,7 @@ public class EDDataServiceImpl implements EDDataService {
String fileType = EleCommonUtil.getFileType(fileFullName);
// 获取文件名称
String fileName = EleCommonUtil.getFileName(fileFullName);
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), "文件名不符合规范,只能包含中文字符、下划线、连字符、加号、数字和英文字符");
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), "文件名不符合规范,只能包含中文字符、下划线、连字符、加号、数字和英文字符且长度小于32。");
// 判断文件名称是否存在
EDDataParams folderParames = new EDDataParams();
folderParames.setParentId(categoryId);

View File

@ -31,6 +31,9 @@ public final class EleCommonUtil {
}
public static boolean isFileNameValid(String fileFullName) {
if (fileFullName.length() > 32) {
return false;
}
return pattern.matcher(fileFullName).matches();
}