Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion web/app/components/base/file-uploader/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,23 @@ export const useFile = (fileConfig: FileUpload) => {
const text = e.clipboardData?.getData('text/plain')
if (file && !text) {
e.preventDefault()

const allowedFileTypes = fileConfig.allowed_file_types || []
const fileType = getSupportFileType(file.name, file.type, allowedFileTypes?.includes(SupportUploadFileTypes.custom))
const isFileTypeAllowed = allowedFileTypes.includes(fileType)

// Check if file type is in allowed list
if (!isFileTypeAllowed || !fileConfig.enabled) {
Comment thread
crazywoola marked this conversation as resolved.
notify({
type: 'error',
message: t('common.fileUploader.fileExtensionNotSupport'),
})
return
}

handleLocalFileUpload(file)
}
}, [handleLocalFileUpload])
}, [handleLocalFileUpload, fileConfig, notify, t])

const [isDragActive, setIsDragActive] = useState(false)
const handleDragFileEnter = useCallback((e: React.DragEvent<HTMLElement>) => {
Expand Down
Loading