add(req-2080):创建文件夹,添加兜底逻辑

This commit is contained in:
胡朝飞 2024-01-22 11:31:53 +08:00
parent be908387fb
commit 4b6e0e8f2a

View File

@ -651,6 +651,7 @@ public class FileServiceImpl implements FileService {
java.io.File tempDirectory = new java.io.File(filePath);
if (!tempDirectory.exists()) {
boolean flag = tempDirectory.mkdirs();
log.info("创建文件夹,{}", tempDirectory);
if (flag) {
log.info("临时文件夹创建成功,{}", flag);
} else {
@ -659,6 +660,11 @@ public class FileServiceImpl implements FileService {
absolutePath = rootDir + SEPARATOR + fileName;
}
}
if (!tempDirectory.exists()) {
// 兜底
absolutePath = rootDir + SEPARATOR + fileName;
}
log.info("临时文件夹,{}", absolutePath);
// 创建输出流并写入数据
OutputStream output = Files.newOutputStream(Paths.get(absolutePath));