|
@@ -76,10 +76,12 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
|
|
|
|
|
|
String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS");
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
- String suffix = StringUtils.substringAfterLast(fileName, ".");
|
|
|
- if (suffix.length() > 50) {
|
|
|
+ // 文件名校验长度
|
|
|
+ String prefix = StringUtils.substringBeforeLast(fileName, ".");
|
|
|
+ if (prefix.length() > 50) {
|
|
|
return Result.failure(3003, "文件名称不允许超过50个字节");
|
|
|
}
|
|
|
+ String suffix = StringUtils.substringAfterLast(fileName, ".");
|
|
|
String newName = time + "." +suffix;
|
|
|
String dirType = "fodder/";
|
|
|
long size = file.getSize();
|
|
@@ -234,4 +236,15 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
|
|
|
return entityMapper.findBySceneCode(sceneCode);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void test1(){
|
|
|
+ String fileName = "15un_fd_manage_data/fd720_0ARhvh11b/fd720_0ARhvh11b.jpg";
|
|
|
+ String suffix = StringUtils.substringBeforeLast(fileName, ".");
|
|
|
+ log.info("suffix: {}", suffix);
|
|
|
+ if (suffix.length() > 50) {
|
|
|
+ log.error("文件名称不允许超过50个字节");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|