From 3b969d2cd11e2bff3402cdc5e8825b105b453630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Sun, 11 Dec 2022 14:10:54 +0100 Subject: [PATCH] fix(Move Binary Data Node): Stringify objects before encoding them in MoveBinaryData (#4882) * stringify objects before encoding them objects in MoveBinaryData * add fileSize and fileType on MoveBinaryData converted data * show `view` option for text files as well * improve how JSON binary data is shown in the UI --- packages/core/src/NodeExecuteFunctions.ts | 9 +--- .../src/components/BinaryDataDisplay.vue | 6 ++- .../src/components/BinaryDataDisplayEmbed.vue | 52 ++++++++++++++----- packages/editor-ui/src/components/RunData.vue | 8 +-- .../MoveBinaryData/MoveBinaryData.node.ts | 26 ++++++---- packages/nodes-base/package.json | 1 + packages/workflow/src/Interfaces.ts | 2 +- packages/workflow/src/index.ts | 2 +- packages/workflow/src/utils.ts | 10 ++++ pnpm-lock.yaml | 2 + 10 files changed, 80 insertions(+), 38 deletions(-) diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 990c9a78c3..cd525a3d75 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -64,7 +64,7 @@ import { NodeExecutionWithMetadata, IPairedItemData, deepCopy, - BinaryFileType, + fileTypeFromMimeType, } from 'n8n-workflow'; import { Agent } from 'https'; @@ -836,13 +836,6 @@ export async function getBinaryDataBuffer( return BinaryDataManager.getInstance().retrieveBinaryData(binaryData); } -function fileTypeFromMimeType(mimeType: string): BinaryFileType | undefined { - if (mimeType.startsWith('image/')) return 'image'; - if (mimeType.startsWith('video/')) return 'video'; - if (mimeType.startsWith('text/') || mimeType.startsWith('application/json')) return 'text'; - return; -} - /** * Store an incoming IBinaryData & related buffer using the configured binary data manager. * diff --git a/packages/editor-ui/src/components/BinaryDataDisplay.vue b/packages/editor-ui/src/components/BinaryDataDisplay.vue index 8ef83d206d..4f7656662c 100644 --- a/packages/editor-ui/src/components/BinaryDataDisplay.vue +++ b/packages/editor-ui/src/components/BinaryDataDisplay.vue @@ -1,5 +1,5 @@