fix(knowledge): 修复文件上传失败

This commit is contained in:
v-zhangjc9
2025-05-30 11:03:26 +08:00
parent 2cac589b0f
commit b8cc8fee67
3 changed files with 3 additions and 14 deletions

View File

@@ -65,7 +65,7 @@ public class DataFileController {
File targetFile = new File(StrUtil.format("{}/{}", uploadFolderPath, originMd5)); File targetFile = new File(StrUtil.format("{}/{}", uploadFolderPath, originMd5));
if (targetFile.exists()) { if (targetFile.exists()) {
dataFileService.updateDataFile(id, FileUtil.getAbsolutePath(targetFile), FileUtil.size(targetFile), originMd5, file.getContentType()); dataFileService.updateDataFile(id, FileUtil.getAbsolutePath(targetFile), FileUtil.size(targetFile), originMd5, file.getContentType());
return AmisResponse.responseSuccess(new FinishResponse(id, filename, url, url)); return AmisResponse.responseSuccess(new FinishResponse(id, filename, String.valueOf(id), url));
} }
File cacheFile = new File(StrUtil.format("{}/{}", cacheFolderPath, id)); File cacheFile = new File(StrUtil.format("{}/{}", cacheFolderPath, id));
cacheFile = FileUtil.writeBytes(bytes, cacheFile); cacheFile = FileUtil.writeBytes(bytes, cacheFile);
@@ -75,7 +75,7 @@ public class DataFileController {
} }
FileUtil.move(cacheFile, targetFile, true); FileUtil.move(cacheFile, targetFile, true);
dataFileService.updateDataFile(id, FileUtil.getAbsolutePath(targetFile), FileUtil.size(targetFile), targetMd5, file.getContentType()); dataFileService.updateDataFile(id, FileUtil.getAbsolutePath(targetFile), FileUtil.size(targetFile), targetMd5, file.getContentType());
return AmisResponse.responseSuccess(new FinishResponse(id, filename, url, url)); return AmisResponse.responseSuccess(new FinishResponse(id, filename, String.valueOf(id), url));
} }
@GetMapping("/download/{id}") @GetMapping("/download/{id}")

View File

@@ -76,16 +76,4 @@ public class DataFileService {
id id
); );
} }
public static final class DataFileNotFoundException extends RuntimeException {
public DataFileNotFoundException() {
super("文件未找到,请重新上传");
}
}
public static final class UpdateDataFileFailedException extends RuntimeException {
public UpdateDataFileFailedException() {
super("更新文件信息失败,请重新上传");
}
}
} }

View File

@@ -176,6 +176,7 @@ deploy:
jdk: "jdk17" jdk: "jdk17"
replicas: 1 replicas: 1
arguments: arguments:
"[knowledge.download-prefix]": 'http://132.126.207.130:35690/hudi_services/ai_knowledge'
"[knowledge.upload-path]": ${deploy.runtime.data-path}/knowledge "[knowledge.upload-path]": ${deploy.runtime.data-path}/knowledge
"[spring.datasource.url]": ${deploy.runtime.database.config.url} "[spring.datasource.url]": ${deploy.runtime.database.config.url}
"[spring.datasource.username]": ${deploy.runtime.database.config.username} "[spring.datasource.username]": ${deploy.runtime.database.config.username}