mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 15:31:05 +08:00
fix: move agent attachment download api (#15146)
### What problem does this PR solve? move agent attachment download api to the correct route and update frontend callers ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) ### Notes - Move the attachment download endpoint from document routes to agent routes. - Update frontend download callers to use the agent attachment endpoint. - Reuse the shared file response header helper instead of duplicating it in `agent_api.py`.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { IDocumentDownloadInfo } from '@/interfaces/database/chat';
|
||||
import { downloadFile } from '@/services/file-manager-service';
|
||||
import { downloadAgentFile } from '@/services/file-manager-service';
|
||||
import { downloadFileFromBlob } from '@/utils/file-util';
|
||||
import { Download, FileText } from 'lucide-react';
|
||||
import { useCallback } from 'react';
|
||||
@@ -20,7 +20,7 @@ export function DocumentDownloadButton({
|
||||
try {
|
||||
const ext =
|
||||
downloadInfo.filename.split('.').pop()?.toLowerCase() || 'bin';
|
||||
const response = await downloadFile({
|
||||
const response = await downloadAgentFile({
|
||||
docId: downloadInfo.doc_id,
|
||||
ext,
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
import { useSetModalState } from '@/hooks/common-hooks';
|
||||
import { IRemoveMessageById } from '@/hooks/logic-hooks';
|
||||
import { AgentChatContext } from '@/pages/agent/context';
|
||||
import { downloadFile } from '@/services/file-manager-service';
|
||||
import { downloadAgentFile } from '@/services/file-manager-service';
|
||||
import { downloadFileFromBlob } from '@/utils/file-util';
|
||||
import {
|
||||
DeleteOutlined,
|
||||
@@ -125,7 +125,7 @@ export const AssistantGroupButton = ({
|
||||
value="g"
|
||||
onClick={async () => {
|
||||
try {
|
||||
const response = await downloadFile({
|
||||
const response = await downloadAgentFile({
|
||||
docId: attachment.doc_id,
|
||||
ext: attachment.format,
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ const {
|
||||
getFile,
|
||||
moveFile,
|
||||
getDatasetDocumentFileDownload,
|
||||
getDocumentFileDownload,
|
||||
getAttachmentFileDownload,
|
||||
} = api;
|
||||
|
||||
const methods = {
|
||||
@@ -62,8 +62,8 @@ const fileManagerService = registerServer<keyof typeof methods>(
|
||||
request,
|
||||
);
|
||||
|
||||
export const downloadFile = (data: { docId: string; ext: string }) => {
|
||||
return request.get(getDocumentFileDownload(data.docId), {
|
||||
export const downloadAgentFile = (data: { docId: string; ext: string }) => {
|
||||
return request.get(getAttachmentFileDownload(data.docId), {
|
||||
params: { ext: data.ext },
|
||||
responseType: 'blob',
|
||||
});
|
||||
|
||||
@@ -129,8 +129,6 @@ export default {
|
||||
`${restAPIv1}/datasets/${datasetId}/documents/${documentId}`,
|
||||
documentThumbnails: `${restAPIv1}/thumbnails`,
|
||||
getDocumentFile: `${restAPIv1}/documents`,
|
||||
getDocumentFileDownload: (docId: string) =>
|
||||
`${restAPIv1}/documents/${docId}/download`,
|
||||
documentUpload: (datasetId: string) =>
|
||||
`${restAPIv1}/datasets/${datasetId}/documents`,
|
||||
webCrawl: (datasetId: string) =>
|
||||
@@ -223,6 +221,8 @@ export default {
|
||||
`${restAPIv1}/agentbots/${canvasId}/inputs`,
|
||||
prompt: `${restAPIv1}/agents/prompts`,
|
||||
cancelDataflow: (id: string) => `${restAPIv1}/tasks/${id}/cancel`,
|
||||
getAttachmentFileDownload: (docId: string) =>
|
||||
`${restAPIv1}/agents/${docId}/download`,
|
||||
downloadFile: `${restAPIv1}/agents/download`,
|
||||
testWebhook: (id: string) => `${restAPIv1}/agents/${id}/webhook/test`,
|
||||
fetchWebhookTrace: (id: string) => `${restAPIv1}/agents/${id}/webhook/logs`,
|
||||
|
||||
Reference in New Issue
Block a user