fix:本地文件上传win系统生成路径问题

This commit is contained in:
ruying408
2025-02-07 08:05:58 +08:00
parent 5189c250c9
commit 8819690870
2 changed files with 4 additions and 3 deletions

View File

@@ -43,15 +43,15 @@ public class LocalFileUploadStrategy implements FileUploadStrategy {
String date = DateUtil.format(new Date(),
DatePattern.PURE_DATE_PATTERN);
String absoluteUploadFolder = localFileProperties.getAbsoluteUploadFolder();
String fullPath = absoluteUploadFolder + File.separator + date;
String fullPath = absoluteUploadFolder + "/" + date;
FileUtil.mkdir(fullPath);
for (MultipartFile file : files) {
// 保存文件
String fileName = StrUtil.uuid().replaceAll("-", "") + getExtensionName(
Objects.requireNonNull(file.getOriginalFilename()));
file.transferTo(new File(fullPath
+ File.separator + fileName));
fileUrls.add(baseUrl + File.separator + date + File.separator + fileName);
+ "/" + fileName));
fileUrls.add(baseUrl + "/" + date + "/" + fileName);
}
if (fileUrls.size() == 1) {
return fileUrls.get(0);

View File

@@ -1,3 +1,4 @@
✨🌈✨[cool-admin-java-plus](https://gitee.com/hlc4417/cool-admin-java-plus)✨🌈✨
______ ___ ___ _____ _ ______ ____ ____ _____ ____ _____
.' ___ | .' `. .' `.|_ _| V7.x / \ |_ _ `.|_ \ / _||_ _||_ \|_ _|
/ .' \_|/ .-. \/ .-. \ | | ______ / _ \ | | `. \ | \/ | | | | \ | |