Fix/upload limit (#2521)

Co-authored-by: jyong <jyong@dify.ai>
Co-authored-by: StyleZhang <jasonapring2015@outlook.com>
This commit is contained in:
Jyong
2024-02-22 17:16:22 +08:00
committed by GitHub
parent 52b12ed7eb
commit 97fe817186
12 changed files with 97 additions and 14 deletions

View File

@@ -14,6 +14,8 @@ import { fetchSupportFileTypes } from '@/service/datasets'
import I18n from '@/context/i18n'
import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language'
const FILES_NUMBER_LIMIT = 20
type IFileUploaderProps = {
fileList: FileItem[]
titleClassName?: string
@@ -176,6 +178,11 @@ const FileUploader = ({
if (!files.length)
return false
if (files.length + fileList.length > FILES_NUMBER_LIMIT) {
notify({ type: 'error', message: t('datasetCreation.stepOne.uploader.validation.filesNumber', { filesNumber: FILES_NUMBER_LIMIT }) })
return false
}
const preparedFiles = files.map((file, index) => ({
fileID: `file${index}-${Date.now()}`,
file,
@@ -185,7 +192,7 @@ const FileUploader = ({
prepareFileList(newFiles)
fileListRef.current = newFiles
uploadMultipleFiles(preparedFiles)
}, [prepareFileList, uploadMultipleFiles])
}, [prepareFileList, uploadMultipleFiles, notify, t, fileList])
const handleDragEnter = (e: DragEvent) => {
e.preventDefault()

View File

@@ -28,6 +28,7 @@ const translation = {
typeError: 'File type not supported',
size: 'File too large. Maximum is {{size}}MB',
count: 'Multiple files not supported',
filesNumber: 'You have reached the batch upload limit of {{filesNumber}}.',
},
cancel: 'Cancel',
change: 'Change',

View File

@@ -28,6 +28,7 @@ const translation = {
typeError: 'Tipo de arquivo não suportado',
size: 'Arquivo muito grande. Máximo é {{size}}MB',
count: 'Vários arquivos não suportados',
filesNumber: 'Limite de upload em massa {{filesNumber}}.',
},
cancel: 'Cancelar',
change: 'Alterar',

View File

@@ -28,6 +28,7 @@ const translation = {
typeError: 'Тип файлу не підтримується',
size: 'Файл занадто великий. Максимум {{size}} МБ',
count: 'Не підтримується завантаження кількох файлів',
filesNumber: 'Ліміт масового завантаження {{filesNumber}}.',
},
cancel: 'Скасувати',
change: 'Змінити',

View File

@@ -28,6 +28,7 @@ const translation = {
typeError: '文件类型不支持',
size: '文件太大了,不能超过 {{size}}MB',
count: '暂不支持多个文件',
filesNumber: '批量上传限制 {{filesNumber}}。',
},
cancel: '取消',
change: '更改文件',