|
@@ -55,6 +55,7 @@ public class FileUtils {
|
|
|
* @return map
|
|
|
*/
|
|
|
public Map<String, Object> uploadMap(MultipartFile file, String savePath, boolean isPinYinRename) {
|
|
|
+
|
|
|
String newName = this.upload(file, savePath, isPinYinRename);
|
|
|
HashMap<String, Object> result = new HashMap<>();
|
|
|
result.put("fileName", file.getOriginalFilename());
|
|
@@ -72,6 +73,7 @@ public class FileUtils {
|
|
|
*/
|
|
|
public String upload(MultipartFile file, String savePath, boolean isPinYinRename) {
|
|
|
|
|
|
+ log.info("执行文件写入服务器");
|
|
|
// 检查非法文件上传
|
|
|
boolean checkFile = this.checkFile(file);
|
|
|
if (!checkFile) {
|
|
@@ -86,7 +88,8 @@ public class FileUtils {
|
|
|
newName = RegexUtil.getPinyinName(fileName);
|
|
|
} else {
|
|
|
String suffix = StringUtils.substringAfterLast(fileName, ".");
|
|
|
- newName = this.getDateTime() + ATOMIC_INTEGER.incrementAndGet() + "." + suffix;
|
|
|
+ String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS");
|
|
|
+ newName = time + ATOMIC_INTEGER.incrementAndGet() + "." + suffix;
|
|
|
}
|
|
|
|
|
|
savePath = configConstant.serverBasePath + savePath + "/" + newName;
|
|
@@ -103,11 +106,6 @@ public class FileUtils {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private static String getDateTime(){
|
|
|
- return DateUtil.format(LocalDateTime.now(), "YYYYMMDD_HHMMSSSSS");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 多文件上传
|
|
|
* savePath 路径(目录)
|