编码文件名修改为uuid方式

This commit is contained in:
RuoYi 2020-07-17 09:24:04 +08:00
parent 4088463adf
commit 2211a75704
3 changed files with 3 additions and 16 deletions

View File

@ -9,8 +9,8 @@ import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException;
import com.ruoyi.common.exception.file.FileSizeLimitExceededException;
import com.ruoyi.common.exception.file.InvalidExtensionException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.IdUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.Md5Utils;
import com.ruoyi.framework.config.RuoYiConfig;
/**
@ -35,8 +35,6 @@ public class FileUploadUtils
*/
private static String defaultBaseDir = RuoYiConfig.getProfile();
private static int counter = 0;
public static void setDefaultBaseDir(String defaultBaseDir)
{
FileUploadUtils.defaultBaseDir = defaultBaseDir;
@ -125,7 +123,7 @@ public class FileUploadUtils
{
String fileName = file.getOriginalFilename();
String extension = getExtension(file);
fileName = DateUtils.datePath() + "/" + encodingFilename(fileName) + "." + extension;
fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
return fileName;
}
@ -152,16 +150,6 @@ public class FileUploadUtils
return pathFileName;
}
/**
* 编码文件名
*/
private static final String encodingFilename(String fileName)
{
fileName = fileName.replace("_", " ");
fileName = Md5Utils.hash(fileName + System.nanoTime() + counter++);
return fileName;
}
/**
* 文件大小校验
*

View File

@ -1,4 +1,4 @@
package com.ruoyi.common.utils.security;
package com.ruoyi.common.utils.sign;
import java.security.MessageDigest;
import org.slf4j.Logger;

View File

@ -454,5 +454,4 @@ public class SysUserServiceImpl implements ISysUserService
}
return successMsg.toString();
}
}