From 2a6629d435af55bb6508470d065d4aba97a66641 Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 29 Aug 2024 11:50:42 +0800 Subject: [PATCH] feat: binary files --- .../nodes/http/components/edit-body/index.tsx | 13 +++++++++---- web/app/components/workflow/nodes/http/types.ts | 1 - 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/web/app/components/workflow/nodes/http/components/edit-body/index.tsx b/web/app/components/workflow/nodes/http/components/edit-body/index.tsx index 8997254c92..301ab81c92 100644 --- a/web/app/components/workflow/nodes/http/components/edit-body/index.tsx +++ b/web/app/components/workflow/nodes/http/components/edit-body/index.tsx @@ -89,7 +89,7 @@ const EditBody: FC = ({ }, [onChange, payload]) const filterOnlyFileVariable = (varPayload: Var) => { - return varPayload.type === VarType.file + return [VarType.file, VarType.arrayFile].includes(varPayload.type) } const handleBodyValueChange = useCallback((value: string) => { @@ -109,7 +109,13 @@ const EditBody: FC = ({ const handleBinaryFileChange = useCallback((value: ValueSelector | string) => { const newBody = produce(payload, (draft: Body) => { - draft.binaryFileVariable = value as ValueSelector + if ((draft.data as BodyPayload).length === 0) { + (draft.data as BodyPayload).push({ + id: uniqueId(UNIQUE_ID_PREFIX), + type: BodyPayloadValueType.file, + }) + } + (draft.data as BodyPayload)[0].file = value as ValueSelector }) onChange(newBody) }, [onChange, payload]) @@ -172,12 +178,11 @@ const EditBody: FC = ({ /> )} - {/* TODO */} {type === BodyType.binary && ( diff --git a/web/app/components/workflow/nodes/http/types.ts b/web/app/components/workflow/nodes/http/types.ts index ad92e6786e..144f2c3eba 100644 --- a/web/app/components/workflow/nodes/http/types.ts +++ b/web/app/components/workflow/nodes/http/types.ts @@ -39,7 +39,6 @@ export type BodyPayload = { export type Body = { type: BodyType data: string | BodyPayload // string is deprecated, it would convert to BodyPayload after loaded - binaryFileVariable?: ValueSelector } export enum AuthorizationType {