Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
632b676 to
0fa5714
Compare
2. File download requests are made to the backend interface, instead of directly accessing Minio.
0fa5714 to
9f6444c
Compare
2. File download requests are made to the backend interface, instead of directly accessing Minio.
2. File download requests are made to the backend interface, instead of directly accessing Minio.
96080fe to
2e8d4f9
Compare
xuyaqist
reviewed
Dec 4, 2025
Comment on lines
+246
to
+309
| // Handle datamate source type separately | ||
| if (source_type === "datamate") { | ||
| if (!datamateDatasetId || !datamateFileId || !datamateBaseUrl) { | ||
| if (!url || url === "#") { | ||
| message.error(t("chatRightPanel.fileDownloadError", "Missing Datamate dataset or file information")); | ||
| return; | ||
| } | ||
| } | ||
| await storageService.downloadDatamateFile({ | ||
| url: url !== "#" ? url : undefined, | ||
| baseUrl: datamateBaseUrl, | ||
| datasetId: datamateDatasetId, | ||
| fileId: datamateFileId, | ||
| filename: filename || undefined, | ||
| }); | ||
| message.success(t("chatRightPanel.fileDownloadSuccess", "File download started")); | ||
| return; | ||
| } | ||
|
|
||
| // Check if URL is a direct http/https URL that can be accessed directly | ||
| // Exclude backend API endpoints (containing /api/file/download/) | ||
| if ( | ||
| url && | ||
| url !== "#" && | ||
| (url.startsWith("http://") || url.startsWith("https://")) && | ||
| !url.includes("/api/file/download/") | ||
| ) { | ||
| // Direct download from HTTP/HTTPS URL without backend | ||
| const link = document.createElement("a"); | ||
| link.href = url; | ||
| link.download = filename || "download"; | ||
| link.style.display = "none"; | ||
| document.body.appendChild(link); | ||
| link.click(); | ||
| setTimeout(() => { | ||
| document.body.removeChild(link); | ||
| }, 100); | ||
| message.success(t("chatRightPanel.fileDownloadSuccess", "File download started")); | ||
| return; | ||
| } | ||
|
|
||
| // Handle regular file source type | ||
| // For knowledge base files, backend stores the MinIO object_name in path_or_url, | ||
| // so we should always try to extract it from the URL and avoid guessing from filename. | ||
| let objectName: string | undefined = undefined; | ||
|
|
||
| if (url && url !== "#") { | ||
| objectName = extractObjectNameFromImageUrl(url) || undefined; | ||
| } | ||
|
|
||
| if (!objectName) { | ||
| message.error(t("chatRightPanel.fileDownloadError", "Cannot determine file object name")); | ||
| return; | ||
| } | ||
|
|
||
| await storageService.downloadFile(objectName, filename || "download"); | ||
| message.success(t("chatRightPanel.fileDownloadSuccess", "File download started")); | ||
| } catch (error) { | ||
| log.error("Failed to download file:", error); | ||
| message.error(t("chatRightPanel.fileDownloadError", "Failed to download file. Please try again.")); | ||
| } finally { | ||
| setIsDownloading(false); | ||
| } | ||
| }; |
Contributor
There was a problem hiding this comment.
这里只判断了source_type为datamate的情况,当下载了文件之后,会通过return强制退出函数。理论上应该采取:
if (url && url !== "#") {
if (source_type === "datamate") {
await storageService.downloadDatamateFile
} else { //默认使用这个进行下载,后续如果需要支持其他来源的文件下载,可以在这里再添加判断。
await storageService.downloadFile(objectName, filename || "download");
}
} else { // 统一判断url
message.error(t("chatRightPanel.fileDownloadError", "Missing Datamate dataset or file information"));
return;
}
WMC001
reviewed
Dec 4, 2025
WMC001
reviewed
Dec 4, 2025
WMC001
reviewed
Dec 4, 2025
WMC001
approved these changes
Dec 4, 2025
2e8d4f9 to
4095952
Compare
2. File download requests are made to the backend interface, instead of directly accessing Minio.
4095952 to
7a2e178
Compare
Phinease
approved these changes
Dec 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✨ 1. Knowledge base tracing results support downloading.
1、知识库溯源结果(nexent、datamate)支持文件下载
2、知识库溯源结果,说明分片知识来源(nexent、datamate)
3、修复直接访问Minio URL下载文件问题。当前通过前端调用后端下载文件接口,返回文件流,并通过浏览器下载文件。
https://github.com/user-attachments/assets/c6c21899-3532-4fde-a822-37702350983c
