Commit e73893f6 by gdj

尝试修改oss文件回传问题。

parent c5d9d9ee
......@@ -196,7 +196,12 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ
file.setPath(path);
file.setObjectKey(moveFilePath + "/" + callback.getFile().getName());
try {
moveFile(orgFilePath, moveFilePath, callback.getFile().getName());
} catch (Exception e) {
log.error("Failed to move file for temporary task: {}", e.getMessage());
// 继续执行,不中断流程
}
} else {
// 查询 任务的orgId
String orgId = "";
......@@ -227,7 +232,12 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ
file.setPath(path);
file.setObjectKey(moveFilePath + "/" + callback.getFile().getName());
try {
moveFile(orgFilePath, moveFilePath, callback.getFile().getName());
} catch (Exception e) {
log.error("Failed to move file for wayline job: {}", e.getMessage());
// 继续执行,不中断流程
}
} else {
file.setPath(path);
}
......@@ -243,12 +253,17 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ
boolean created = directory.mkdirs();
}
Path source = Paths.get(basePath, OssConfiguration.bucket, sourceFilePath, fileName);
// 检查源文件是否存在
if (!Files.exists(source)) {
log.warn("Source file does not exist: {}", source);
return; // 源文件不存在时直接返回,不抛出异常
}
Path targetDir = Paths.get(basePath, OssConfiguration.bucket, targetFilePath);
if (!Files.exists(targetDir)) {
Files.createDirectories(targetDir);
}
Path target = targetDir.resolve(fileName);
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
}
private void notifyUploadedCount(MediaFileCountDTO mediaFileCount, TopicEventsRequest<FileUploadCallback> request, String jobId, DeviceDTO dock) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment