From 93b8f3b5606ad16091e567657be5ca99b82e0c33 Mon Sep 17 00:00:00 2001 From: StyleZhang Date: Thu, 31 Oct 2024 14:41:04 +0800 Subject: [PATCH] fix: upload remote file --- web/app/components/base/file-uploader/hooks.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/app/components/base/file-uploader/hooks.ts b/web/app/components/base/file-uploader/hooks.ts index 1288f383b9..a78c414913 100644 --- a/web/app/components/base/file-uploader/hooks.ts +++ b/web/app/components/base/file-uploader/hooks.ts @@ -226,6 +226,10 @@ export const useFile = (fileConfig: FileUpload) => { uploadedId: res.id, url: res.url, } + if (!isAllowedFileExtension(res.name, res.mime_type, fileConfig.allowed_file_types || [], fileConfig.allowed_file_extensions || [])) { + notify({ type: 'error', message: t('common.fileUploader.fileExtensionNotSupport') }) + handleRemoveFile(uploadingFile.id) + } if (!checkSizeLimit(newFile.supportFileType, newFile.size)) handleRemoveFile(uploadingFile.id) else @@ -234,7 +238,7 @@ export const useFile = (fileConfig: FileUpload) => { notify({ type: 'error', message: t('common.fileUploader.pasteFileLinkInvalid') }) handleRemoveFile(uploadingFile.id) }) - }, [checkSizeLimit, handleAddFile, handleUpdateFile, notify, t, handleRemoveFile, fileConfig?.allowed_file_types, startProgressTimer]) + }, [checkSizeLimit, handleAddFile, handleUpdateFile, notify, t, handleRemoveFile, fileConfig?.allowed_file_types, fileConfig.allowed_file_extensions, startProgressTimer]) const handleLoadFileFromLinkSuccess = useCallback(() => { }, [])