Compare commits

..

No commits in common. "36d1fcbb7ad29a81ee7402314a5e74364d219ddf" and "9739a23d4311873fb3a4b472aaa02cf01e615abb" have entirely different histories.

6 changed files with 13 additions and 16 deletions

View File

@ -19,7 +19,12 @@ public class UploadDataManagementMode {
* 便
*/
private String workspaceId;
/**
*
*
* 便
*/
private String LeaseId;
/**
* ID
*/

View File

@ -28,8 +28,4 @@ public class UploadLeaseParamsMode {
* HTTPURL
*/
private String Url;
private String LeaseId;
}

View File

@ -13,9 +13,9 @@ public class KnowledgeBaseUploadController {
private KnowledgeBaseUploadService knowledgeBaseUploadService;
@PostMapping("/KnowledgeBaseUpload")
public String uploadFile(@RequestParam("file") MultipartFile file) {
public void uploadFile(@RequestParam("file") MultipartFile file) {
String workspaceId = "llm-98lxu358qfvxdxvt";
String categoryId = "cate_997567e8a7e94f4caab94e78c580adb4_10062067";
return knowledgeBaseUploadService.uploadDocument(file, workspaceId, categoryId);
knowledgeBaseUploadService.uploadDocument(file, workspaceId, categoryId);
}
}

View File

@ -3,6 +3,6 @@ package com.muyu.aliyun.service;
import org.springframework.web.multipart.MultipartFile;
public interface KnowledgeBaseUploadService {
String uploadDocument(MultipartFile file, String workspaceId, String categoryId);
void uploadDocument(MultipartFile file, String workspaceId, String categoryId);
}

View File

@ -49,7 +49,7 @@ public class KnowledgeBaseUploadServiceImpl implements KnowledgeBaseUploadServic
private ReviewResolution reviewResolution;
@Override
public String uploadDocument(MultipartFile file, String workspaceId, String categoryId) {
public void uploadDocument(MultipartFile file, String workspaceId, String categoryId) {
try {
// 1. 保存临时文件
File tempFile = convertMultipartFileToFile(file);
@ -67,8 +67,6 @@ public class KnowledgeBaseUploadServiceImpl implements KnowledgeBaseUploadServic
fileUploadLeaseModel.setMd5(md5);
fileUploadLeaseModel.setSizeInBytes(String.valueOf(sizeInBytes));
UploadLeaseParamsMode leaseParams = applyLease.applyFileUploadLease(fileUploadLeaseModel);
if (leaseParams == null) {
throw new RuntimeException("申请文档上传租约失败");
@ -89,7 +87,7 @@ public class KnowledgeBaseUploadServiceImpl implements KnowledgeBaseUploadServic
UploadDataManagementMode uploadDataManagementMode = new UploadDataManagementMode();
uploadDataManagementMode.setWorkspaceId(workspaceId);
// 这里需要设置 LeaseId假设 LeaseId 在 UploadLeaseParamsMode 中有对应的 getter
uploadDataManagementMode.setLeaseId(leaseParams.getLeaseId());
uploadDataManagementMode.setLeaseId("");
AddFileResponseBodyDataMode addFileResult = addDataManagement.addFile(uploadDataManagementMode);
if (addFileResult == null) {
throw new RuntimeException("将文档添加至百炼的数据管理失败");
@ -110,10 +108,8 @@ public class KnowledgeBaseUploadServiceImpl implements KnowledgeBaseUploadServic
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
private File convertMultipartFileToFile(MultipartFile file) throws IOException {
Path tempFilePath = Files.createTempFile(null, null);
File tempFile = tempFilePath.toFile();

View File

@ -7,6 +7,6 @@ oss:
bucketName: idicc-pangu-prod
aliyun:
bailian:
endpoint: oss-cn-hangzhou.aliyuncs.com
endpoint: bailian.cn-beijing.aliyuncs.com
accessKeyId: LTAI5tLvo45NpqjoH11G1beU
accessKeySecret: NjfA4hBwban4W8Db7RBwDJd0pBHJeM
accessKeySecret: NjfA4hBwban4W8Db7RBwDJd0pBHJeM