diff --git a/packages/cli/src/WebhookHelpers.ts b/packages/cli/src/WebhookHelpers.ts index d1046f35fb..eac808d678 100644 --- a/packages/cli/src/WebhookHelpers.ts +++ b/packages/cli/src/WebhookHelpers.ts @@ -426,7 +426,7 @@ export async function executeWebhook( const binaryData = (response.body as IDataObject)?.binaryData as IBinaryData; if (binaryData?.id) { res.header(response.headers); - const stream = NodeExecuteFunctions.getBinaryStream(binaryData.id); + const stream = BinaryDataManager.getInstance().getBinaryStream(binaryData.id); void pipeline(stream, res).then(() => responseCallback(null, { noWebhookResponse: true }), ); @@ -643,10 +643,12 @@ export async function executeWebhook( if (!didSendResponse) { // Send the webhook response manually res.setHeader('Content-Type', binaryData.mimeType); - const binaryDataBuffer = await BinaryDataManager.getInstance().retrieveBinaryData( - binaryData, - ); - res.end(binaryDataBuffer); + if (binaryData.id) { + const stream = BinaryDataManager.getInstance().getBinaryStream(binaryData.id); + await pipeline(stream, res); + } else { + res.end(Buffer.from(binaryData.data, BINARY_ENCODING)); + } responseCallback(null, { noWebhookResponse: true, diff --git a/packages/core/src/BinaryDataManager/index.ts b/packages/core/src/BinaryDataManager/index.ts index bed5a08b10..54ab8bc110 100644 --- a/packages/core/src/BinaryDataManager/index.ts +++ b/packages/core/src/BinaryDataManager/index.ts @@ -121,7 +121,7 @@ export class BinaryDataManager { throw new Error('Storage mode used to store binary data not available'); } - async retrieveBinaryData(binaryData: IBinaryData): Promise { + async getBinaryDataBuffer(binaryData: IBinaryData): Promise { if (binaryData.id) { return this.retrieveBinaryDataByIdentifier(binaryData.id); } diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 13323794b9..38409283e5 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -917,7 +917,7 @@ export async function getBinaryDataBuffer( inputIndex: number, ): Promise { const binaryData = inputData.main[inputIndex]![itemIndex]!.binary![propertyName]!; - return BinaryDataManager.getInstance().retrieveBinaryData(binaryData); + return BinaryDataManager.getInstance().getBinaryDataBuffer(binaryData); } /**