mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 17:38:04 +08:00
refactor(app-asset): migrate file upload to presigned URL and batch upload
- Replace FormData file upload with presigned URL two-step upload - Add batch-upload contract for folder uploads (reduces N+M to 1+M requests) - Remove deprecated createFile contract and useCreateAppAssetFile hook - Remove checksum field from AppAssetNode and AppAssetTreeView types - Add upload-to-presigned-url utility for direct storage uploads
This commit is contained in:
@ -29,8 +29,6 @@ export type AppAssetNode = {
|
||||
extension: string
|
||||
/** File size in bytes, 0 for folders */
|
||||
size: number
|
||||
/** SHA-256 checksum of file content, empty for folders */
|
||||
checksum: string
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,8 +48,6 @@ export type AppAssetTreeView = {
|
||||
extension: string
|
||||
/** File size in bytes */
|
||||
size: number
|
||||
/** SHA-256 checksum */
|
||||
checksum: string
|
||||
/** Child nodes (for folders) */
|
||||
children: AppAssetTreeView[]
|
||||
}
|
||||
@ -138,3 +134,56 @@ export type ReorderNodePayload = {
|
||||
/** Place after this node ID, null for first position */
|
||||
after_node_id: string | null
|
||||
}
|
||||
|
||||
/**
|
||||
* Request payload for getting file upload URL
|
||||
*/
|
||||
export type GetFileUploadUrlPayload = {
|
||||
name: string
|
||||
size: number
|
||||
parent_id?: string | null
|
||||
}
|
||||
|
||||
/**
|
||||
* Response for file upload URL request
|
||||
*/
|
||||
export type FileUploadUrlResponse = {
|
||||
node: AppAssetNode
|
||||
upload_url: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Input node structure for batch upload
|
||||
*/
|
||||
export type BatchUploadNodeInput = {
|
||||
name: string
|
||||
node_type: AssetNodeType
|
||||
size?: number
|
||||
children?: BatchUploadNodeInput[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Output node structure from batch upload (with IDs and upload URLs)
|
||||
*/
|
||||
export type BatchUploadNodeOutput = {
|
||||
id: string
|
||||
name: string
|
||||
node_type: AssetNodeType
|
||||
size: number
|
||||
children: BatchUploadNodeOutput[]
|
||||
upload_url?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Request payload for batch upload
|
||||
*/
|
||||
export type BatchUploadPayload = {
|
||||
children: BatchUploadNodeInput[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Response for batch upload request
|
||||
*/
|
||||
export type BatchUploadResponse = {
|
||||
children: BatchUploadNodeOutput[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user