mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-24 05:23:57 +00:00
fix: file extension check (#2876)
This commit is contained in:
@@ -6,6 +6,7 @@ import { parseCsvTable2Chunks } from './training/utils';
|
||||
import { TextSplitProps, splitText2Chunks } from '@fastgpt/global/common/string/textSplitter';
|
||||
import axios from 'axios';
|
||||
import { readRawContentByFileBuffer } from '../../common/file/read/utils';
|
||||
import { parseFileExtensionFromUrl } from '@fastgpt/global/common/string/tools';
|
||||
|
||||
export const readFileRawTextByUrl = async ({
|
||||
teamId,
|
||||
@@ -21,7 +22,7 @@ export const readFileRawTextByUrl = async ({
|
||||
url: url,
|
||||
responseType: 'arraybuffer'
|
||||
});
|
||||
const extension = url.split('.')?.pop()?.toLowerCase() || '';
|
||||
const extension = parseFileExtensionFromUrl(url);
|
||||
|
||||
const buffer = Buffer.from(response.data, 'binary');
|
||||
|
||||
|
@@ -12,6 +12,7 @@ import { detectFileEncoding } from '@fastgpt/global/common/file/tools';
|
||||
import { readRawContentByFileBuffer } from '../../../../common/file/read/utils';
|
||||
import { ChatRoleEnum } from '@fastgpt/global/core/chat/constants';
|
||||
import { UserChatItemValueItemType } from '@fastgpt/global/core/chat/type';
|
||||
import { parseFileExtensionFromUrl } from '@fastgpt/global/common/string/tools';
|
||||
|
||||
type Props = ModuleDispatchProps<{
|
||||
[NodeInputKeyEnum.fileUrlList]: string[];
|
||||
@@ -144,7 +145,8 @@ export const dispatchReadFiles = async (props: Props): Promise<Response> => {
|
||||
return url;
|
||||
})();
|
||||
// Extension
|
||||
const extension = filename.split('.').pop()?.toLowerCase() || '';
|
||||
const extension = parseFileExtensionFromUrl(filename);
|
||||
|
||||
// Get encoding
|
||||
const encoding = (() => {
|
||||
const contentType = response.headers['content-type'];
|
||||
|
Reference in New Issue
Block a user