add(req-2080):创建linux服务器临时目录
This commit is contained in:
parent
e7adaa2d9a
commit
1bfc319140
@ -642,14 +642,16 @@ public class FileServiceImpl implements FileService {
|
||||
input = file.getInputStream();
|
||||
// 指定目标文件路径及文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
|
||||
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
String classPath = Objects.requireNonNull(contextClassLoader.getResource("")).getPath();
|
||||
log.info("linux服务器下的类文件路径:{}", classPath);
|
||||
String projectPath = classPath.substring(0, classPath.indexOf("/target/classes/"));
|
||||
log.info("linux服务器下的项目路径:{}", projectPath);
|
||||
|
||||
String filePath = projectPath + SEPARATOR + "temp_directory";
|
||||
String osName = System.getProperty("os.name");
|
||||
String rootDir = null;
|
||||
if (Objects.nonNull(osName) && osName.toLowerCase().startsWith("linux")) {
|
||||
rootDir = "/mnt/tem/obs";
|
||||
} else {
|
||||
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
String classPath = Objects.requireNonNull(contextClassLoader.getResource("")).getPath();
|
||||
rootDir = classPath.substring(0, classPath.indexOf("/target/classes/"));
|
||||
}
|
||||
String filePath = rootDir + SEPARATOR + "temp_directory";
|
||||
String absolutePath = filePath + SEPARATOR + fileName;
|
||||
|
||||
// 创建临时文件夹
|
||||
@ -661,12 +663,12 @@ public class FileServiceImpl implements FileService {
|
||||
} else {
|
||||
log.info("临时文件夹创建失败,{}", flag);
|
||||
// 兜底
|
||||
absolutePath = projectPath + SEPARATOR + fileName;
|
||||
absolutePath = rootDir + SEPARATOR + fileName;
|
||||
}
|
||||
}
|
||||
if (!tempDirectory.exists()) {
|
||||
// 兜底
|
||||
absolutePath = projectPath + SEPARATOR + fileName;
|
||||
absolutePath = rootDir + SEPARATOR + fileName;
|
||||
}
|
||||
log.info("临时文件绝对路径:{}", absolutePath);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user