编码文件名修改为uuid方式
This commit is contained in:
parent
4088463adf
commit
2211a75704
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件大小校验
|
||||
*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.ruoyi.common.utils.security;
|
||||
package com.ruoyi.common.utils.sign;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import org.slf4j.Logger;
|
|
@ -454,5 +454,4 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
}
|
||||
return successMsg.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue