mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 02:39:19 +08:00
fix: 修复处理导入任务获取文件路径错误问题
This commit is contained in:
+7
-6
@@ -185,15 +185,16 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
String filePath = task.getFilePath();
|
||||
File csvFile;
|
||||
|
||||
if (filePath.startsWith("/")) {
|
||||
// 以/开头的路径,去掉开头的/,转换为相对于项目根目录的路径
|
||||
csvFile = new File(System.getProperty("user.dir"), filePath.substring(1));
|
||||
} else if (filePath.contains(":")) {
|
||||
if (filePath.contains(":")) {
|
||||
// 包含:的路径,认为是绝对路径(Windows路径如 C:\...)
|
||||
csvFile = new File(filePath);
|
||||
} else if (filePath.startsWith("/")) {
|
||||
// 以/开头的路径,去掉开头的/,转换为相对于当前工作目录的路径
|
||||
// 例如:/uploads/files/xxx.csv -> uploads/files/xxx.csv
|
||||
csvFile = new File(filePath.substring(1));
|
||||
} else {
|
||||
// 相对路径,相对于项目根目录
|
||||
csvFile = new File(System.getProperty("user.dir"), filePath);
|
||||
// 相对路径,直接使用
|
||||
csvFile = new File(filePath);
|
||||
}
|
||||
|
||||
if (!csvFile.exists() || !csvFile.isFile()) {
|
||||
|
||||
Reference in New Issue
Block a user