Files
ragflow/web/src/services/file-manager-service.ts
buua436 71a52d579c 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`.
2026-05-22 15:22:05 +08:00

86 lines
1.6 KiB
TypeScript

import api from '@/utils/api';
import registerServer from '@/utils/register-server';
import request from '@/utils/request';
const {
listFile,
removeFile,
uploadFile,
getAllParentFolder,
createFolder,
connectFileToKnowledge,
getDocumentFile,
getFile,
moveFile,
getDatasetDocumentFileDownload,
getAttachmentFileDownload,
} = api;
const methods = {
listFile: {
url: listFile,
method: 'get',
},
removeFile: {
url: removeFile,
method: 'delete',
},
uploadFile: {
url: uploadFile,
method: 'post',
},
getAllParentFolder: {
url: getAllParentFolder,
method: 'get',
},
createFolder: {
url: createFolder,
method: 'post',
},
connectFileToKnowledge: {
url: connectFileToKnowledge,
method: 'post',
},
getFile: {
url: getFile,
method: 'get',
responseType: 'blob',
},
getDocumentFile: {
url: getDocumentFile,
method: 'get',
responseType: 'blob',
},
moveFile: {
url: moveFile,
method: 'post',
},
} as const;
const fileManagerService = registerServer<keyof typeof methods>(
methods,
request,
);
export const downloadAgentFile = (data: { docId: string; ext: string }) => {
return request.get(getAttachmentFileDownload(data.docId), {
params: { ext: data.ext },
responseType: 'blob',
});
};
export const downloadDatasetDocument = (data: {
datasetId: string;
docId: string;
ext: string;
}) => {
return request.get(
getDatasetDocumentFileDownload(data.datasetId, data.docId),
{
params: { ext: data.ext },
responseType: 'blob',
},
);
};
export default fileManagerService;