mirror of
https://github.com/langgenius/dify.git
synced 2026-02-24 20:01:22 +08:00
- Implemented File Upload node with support for uploading files to the sandbox. - Added necessary UI components including node panel and default configurations. - Enhanced workflow constants and enums to include File Upload. - Updated error handling for file upload operations. - Integrated File Upload into existing workflow structure, ensuring compatibility with variable handling and output management. - Added translations for new File Upload features in workflow.json.
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import type { NodeDefault } from '../../types'
|
|
import type { FileUploadNodeType } from './types'
|
|
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
|
import { BlockEnum } from '@/app/components/workflow/types'
|
|
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
|
|
|
const i18nPrefix = 'errorMsg'
|
|
|
|
const metaData = genNodeMetaData({
|
|
classification: BlockClassificationEnum.Utilities,
|
|
sort: 3,
|
|
type: BlockEnum.FileUpload,
|
|
})
|
|
|
|
const nodeDefault: NodeDefault<FileUploadNodeType> = {
|
|
metaData,
|
|
defaultValue: {
|
|
variable_selector: [],
|
|
is_array_file: false,
|
|
},
|
|
checkValid(payload: FileUploadNodeType, t: (key: string, options?: Record<string, unknown>) => string) {
|
|
let errorMessages = ''
|
|
const { variable_selector: variable } = payload
|
|
|
|
if (!errorMessages && !variable?.length)
|
|
errorMessages = t(`${i18nPrefix}.fieldRequired`, { ns: 'workflow', field: t(`${i18nPrefix}.fields.fileVariable`, { ns: 'workflow' }) })
|
|
|
|
return {
|
|
isValid: !errorMessages,
|
|
errorMessage: errorMessages,
|
|
}
|
|
},
|
|
}
|
|
|
|
export default nodeDefault
|