mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 09:58: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:
@ -4,7 +4,11 @@ import type {
|
||||
AppAssetNode,
|
||||
AppAssetPublishResponse,
|
||||
AppAssetTreeResponse,
|
||||
BatchUploadPayload,
|
||||
BatchUploadResponse,
|
||||
CreateFolderPayload,
|
||||
FileUploadUrlResponse,
|
||||
GetFileUploadUrlPayload,
|
||||
MoveNodePayload,
|
||||
RenameNodePayload,
|
||||
ReorderNodePayload,
|
||||
@ -33,16 +37,6 @@ export const createFolderContract = base
|
||||
}>())
|
||||
.output(type<AppAssetNode>())
|
||||
|
||||
export const createFileContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/assets/files',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: { appId: string }
|
||||
}>())
|
||||
.output(type<AppAssetNode>())
|
||||
|
||||
export const getFileContentContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/assets/files/{nodeId}',
|
||||
@ -126,3 +120,25 @@ export const publishContract = base
|
||||
params: { appId: string }
|
||||
}>())
|
||||
.output(type<AppAssetPublishResponse>())
|
||||
|
||||
export const getFileUploadUrlContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/assets/files/upload',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: { appId: string }
|
||||
body: GetFileUploadUrlPayload
|
||||
}>())
|
||||
.output(type<FileUploadUrlResponse>())
|
||||
|
||||
export const batchUploadContract = base
|
||||
.route({
|
||||
path: '/apps/{appId}/assets/batch-upload',
|
||||
method: 'POST',
|
||||
})
|
||||
.input(type<{
|
||||
params: { appId: string }
|
||||
body: BatchUploadPayload
|
||||
}>())
|
||||
.output(type<BatchUploadResponse>())
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import type { InferContractRouterInputs } from '@orpc/contract'
|
||||
import {
|
||||
createFileContract,
|
||||
batchUploadContract,
|
||||
createFolderContract,
|
||||
deleteNodeContract,
|
||||
getFileContentContract,
|
||||
getFileDownloadUrlContract,
|
||||
getFileUploadUrlContract,
|
||||
moveNodeContract,
|
||||
publishContract,
|
||||
renameNodeContract,
|
||||
@ -52,7 +53,6 @@ export const consoleRouterContract = {
|
||||
appAsset: {
|
||||
tree: treeContract,
|
||||
createFolder: createFolderContract,
|
||||
createFile: createFileContract,
|
||||
getFileContent: getFileContentContract,
|
||||
getFileDownloadUrl: getFileDownloadUrlContract,
|
||||
updateFileContent: updateFileContentContract,
|
||||
@ -61,6 +61,8 @@ export const consoleRouterContract = {
|
||||
moveNode: moveNodeContract,
|
||||
reorderNode: reorderNodeContract,
|
||||
publish: publishContract,
|
||||
getFileUploadUrl: getFileUploadUrlContract,
|
||||
batchUpload: batchUploadContract,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user