feat(Webhook Node): Stream binary response in lastNode.firstEntryBinary mode (#6463)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-06-19 13:54:56 +02:00
committed by GitHub
parent 8b50625fb1
commit 6ccab3eaaa
3 changed files with 9 additions and 7 deletions

View File

@@ -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,