Skip to content

Commit 20a7faa

Browse files
committed
适应linux文件路径
1 parent 8109253 commit 20a7faa

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

core/src/main/java/info/xiaomo/core/constant/WebDefaultValueConst.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ public interface WebDefaultValueConst {
1818

1919
String defaultImage = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png";
2020

21-
String imgBaseUrl = System.getProperty("user.dir") + "/static/images";
21+
String imgBaseUrl = "http://static.xiaomo.info/images/";
22+
23+
String saveBaseUrl = "/data2/xiaomo.info/static/images/";
2224
}

core/src/main/java/info/xiaomo/core/untils/FileUtil.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -683,18 +683,18 @@ private static void list(ArrayList list, File file,
683683
* @return fileUrl
684684
*/
685685
public static String upload(MultipartFile file, String email) {
686-
String savePath = "";
686+
String savePath;
687+
String filename = "";
687688
if (file != null && !file.isEmpty()) {
688689
// 获取图片的文件名
689690
String fileName = file.getOriginalFilename();
690691
// 重新定义图片名字
691-
String filename = FileUtil.getNewFileName(fileName, email);
692+
filename = FileUtil.getNewFileName(fileName, email);
692693
//上传服务器上 新文件路径
693-
savePath = WebDefaultValueConst.imgBaseUrl;
694+
savePath = WebDefaultValueConst.saveBaseUrl;
694695
try {
695-
File newFile;
696696
// 判断服务器上 文件夹是否存在
697-
newFile = new File(savePath);
697+
File newFile = new File(savePath);
698698
if (!newFile.exists()) {
699699
newFile.mkdirs();
700700
}
@@ -708,7 +708,7 @@ public static String upload(MultipartFile file, String email) {
708708
e.printStackTrace();
709709
}
710710
}
711-
return savePath;
711+
return WebDefaultValueConst.imgBaseUrl + filename;
712712
}
713713

714714

0 commit comments

Comments
 (0)