fix: file extension check (#2876)

This commit is contained in:
Archer
2024-10-10 17:35:56 +08:00
committed by GitHub
parent 15b8353c7d
commit 3878a50d0f
6 changed files with 28 additions and 5 deletions

View File

@@ -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'];