Skip to content

Commit a705ad0

Browse files
committed
fix(Uploader): 修复文件上传返回的 URL 包含反斜杠问题
在 Windows 平台下,文件上传后返回的 URL 包含了反斜杠
1 parent 9341c88 commit a705ad0

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/main/java/io/github/talelin/latticy/service/impl/FileServiceImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ private FileBO transformDoToBo(FileDO file, String key) {
7070
BeanUtil.copyProperties(file, bo);
7171
if (file.getType().equals(FileConstant.LOCAL)) {
7272
String s = fileProperties.getServePath().split("/")[0];
73-
bo.setUrl(fileProperties.getDomain() + s + "/" + file.getPath());
73+
74+
// replaceAll 是将 windows 平台下的 \ 替换为 /
75+
if(System.getProperties().getProperty("os.name").toUpperCase().contains("WINDOWS")){
76+
bo.setUrl(fileProperties.getDomain() + s + "/" + file.getPath().replaceAll("\\\\","/"));
77+
}else {
78+
bo.setUrl(fileProperties.getDomain() + s + "/" + file.getPath());
79+
}
7480
} else {
7581
bo.setUrl(file.getPath());
7682
}

0 commit comments

Comments
 (0)