mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(Webhook Node): Stream binary response in lastNode.firstEntryBinary mode (#6463)
This commit is contained in:
committed by
GitHub
parent
8b50625fb1
commit
6ccab3eaaa
@@ -426,7 +426,7 @@ export async function executeWebhook(
|
|||||||
const binaryData = (response.body as IDataObject)?.binaryData as IBinaryData;
|
const binaryData = (response.body as IDataObject)?.binaryData as IBinaryData;
|
||||||
if (binaryData?.id) {
|
if (binaryData?.id) {
|
||||||
res.header(response.headers);
|
res.header(response.headers);
|
||||||
const stream = NodeExecuteFunctions.getBinaryStream(binaryData.id);
|
const stream = BinaryDataManager.getInstance().getBinaryStream(binaryData.id);
|
||||||
void pipeline(stream, res).then(() =>
|
void pipeline(stream, res).then(() =>
|
||||||
responseCallback(null, { noWebhookResponse: true }),
|
responseCallback(null, { noWebhookResponse: true }),
|
||||||
);
|
);
|
||||||
@@ -643,10 +643,12 @@ export async function executeWebhook(
|
|||||||
if (!didSendResponse) {
|
if (!didSendResponse) {
|
||||||
// Send the webhook response manually
|
// Send the webhook response manually
|
||||||
res.setHeader('Content-Type', binaryData.mimeType);
|
res.setHeader('Content-Type', binaryData.mimeType);
|
||||||
const binaryDataBuffer = await BinaryDataManager.getInstance().retrieveBinaryData(
|
if (binaryData.id) {
|
||||||
binaryData,
|
const stream = BinaryDataManager.getInstance().getBinaryStream(binaryData.id);
|
||||||
);
|
await pipeline(stream, res);
|
||||||
res.end(binaryDataBuffer);
|
} else {
|
||||||
|
res.end(Buffer.from(binaryData.data, BINARY_ENCODING));
|
||||||
|
}
|
||||||
|
|
||||||
responseCallback(null, {
|
responseCallback(null, {
|
||||||
noWebhookResponse: true,
|
noWebhookResponse: true,
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ export class BinaryDataManager {
|
|||||||
throw new Error('Storage mode used to store binary data not available');
|
throw new Error('Storage mode used to store binary data not available');
|
||||||
}
|
}
|
||||||
|
|
||||||
async retrieveBinaryData(binaryData: IBinaryData): Promise<Buffer> {
|
async getBinaryDataBuffer(binaryData: IBinaryData): Promise<Buffer> {
|
||||||
if (binaryData.id) {
|
if (binaryData.id) {
|
||||||
return this.retrieveBinaryDataByIdentifier(binaryData.id);
|
return this.retrieveBinaryDataByIdentifier(binaryData.id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -917,7 +917,7 @@ export async function getBinaryDataBuffer(
|
|||||||
inputIndex: number,
|
inputIndex: number,
|
||||||
): Promise<Buffer> {
|
): Promise<Buffer> {
|
||||||
const binaryData = inputData.main[inputIndex]![itemIndex]!.binary![propertyName]!;
|
const binaryData = inputData.main[inputIndex]![itemIndex]!.binary![propertyName]!;
|
||||||
return BinaryDataManager.getInstance().retrieveBinaryData(binaryData);
|
return BinaryDataManager.getInstance().getBinaryDataBuffer(binaryData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user