Compare commits

...

3 Commits

Author SHA1 Message Date
Aaaaaaaa 36d1fcbb7a Merge remote-tracking branch 'origin/master' 2025-02-25 20:19:06 +08:00
Aaaaaaaa 39e3fc7edf 111 2025-02-25 19:31:36 +08:00
Aaaaaaaa 53c1f4d84b 111 2025-02-25 17:40:02 +08:00
6 changed files with 16 additions and 13 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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