Skip to content

Commit

Permalink
⚡ do not add binary if binary.data empty
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency committed Dec 6, 2023
1 parent b9572b6 commit bc2c9fa
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/nodes-base/nodes/Webhook/Webhook.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,21 @@ export class Webhook extends Node {
try {
await pipeline(req, createWriteStream(binaryFile.path));

const binaryPropertyName = (options.binaryPropertyName || 'data') as string;
const fileName = req.contentDisposition?.filename ?? uuid();

const binaryData = await context.nodeHelpers.copyBinaryFile(
binaryFile.path,
fileName,
req.contentType ?? 'application/octet-stream',
);

const returnItem: INodeExecutionData = {
binary: {},
binary: binaryData.data
? {
[binaryPropertyName]: binaryData,
}
: {},
json: {
headers: req.headers,
params: req.params,
Expand All @@ -283,14 +296,6 @@ export class Webhook extends Node {
},
};

const binaryPropertyName = (options.binaryPropertyName || 'data') as string;
const fileName = req.contentDisposition?.filename ?? uuid();
returnItem.binary![binaryPropertyName] = await context.nodeHelpers.copyBinaryFile(
binaryFile.path,
fileName,
req.contentType ?? 'application/octet-stream',
);

return { workflowData: [[returnItem]] };
} catch (error) {
throw new NodeOperationError(context.getNode(), error as Error);
Expand Down

0 comments on commit bc2c9fa

Please sign in to comment.