mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-23 06:46:40 +08:00
Web: Fixed the download and preview file not authorized. (#3652)
https://github.com/infiniflow/ragflow/issues/3651 ### What problem does this PR solve? _Briefly describe what this PR aims to solve. Include background context that will help reviewers understand the purpose of the PR._ ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -1,13 +1,12 @@
|
||||
import NewDocumentLink from '@/components/new-document-link';
|
||||
import SvgIcon from '@/components/svg-icon';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useDownloadFile } from '@/hooks/file-manager-hooks';
|
||||
import { IFile } from '@/interfaces/database/file-manager';
|
||||
import { api_host } from '@/utils/api';
|
||||
import {
|
||||
getExtension,
|
||||
isSupportedPreviewDocumentType,
|
||||
} from '@/utils/document-util';
|
||||
import { downloadFile } from '@/utils/file-util';
|
||||
import {
|
||||
DeleteOutlined,
|
||||
DownloadOutlined,
|
||||
@ -42,12 +41,13 @@ const ActionCell = ({
|
||||
[documentId],
|
||||
setSelectedRowKeys,
|
||||
);
|
||||
const { downloadFile, loading } = useDownloadFile();
|
||||
const extension = getExtension(record.name);
|
||||
const isKnowledgeBase = record.source_type === 'knowledgebase';
|
||||
|
||||
const onDownloadDocument = () => {
|
||||
downloadFile({
|
||||
url: `${api_host}/file/get/${documentId}`,
|
||||
id: documentId,
|
||||
filename: record.name,
|
||||
});
|
||||
};
|
||||
@ -106,7 +106,12 @@ const ActionCell = ({
|
||||
)}
|
||||
{record.type !== 'folder' && (
|
||||
<Tooltip title={t('download', { keyPrefix: 'common' })}>
|
||||
<Button type="text" disabled={beingUsed} onClick={onDownloadDocument}>
|
||||
<Button
|
||||
type="text"
|
||||
disabled={beingUsed}
|
||||
loading={loading}
|
||||
onClick={onDownloadDocument}
|
||||
>
|
||||
<DownloadOutlined size={20} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
|
||||
Reference in New Issue
Block a user