diff --git a/packages/nodes-base/nodes/Webhook.node.ts b/packages/nodes-base/nodes/Webhook.node.ts
index 4c1523380..96268eab2 100644
--- a/packages/nodes-base/nodes/Webhook.node.ts
+++ b/packages/nodes-base/nodes/Webhook.node.ts
@@ -246,7 +246,9 @@ export class Webhook implements INodeType {
],
},
},
- description: 'Name of the binary property to which to
write the data of the received file.',
+ description: `Name of the binary property to which to write the data of
+ the received file. If the data gets received via "Form-Data Multipart"
+ it will be the prefix and a number starting with 0 will be attached to it.`,
},
{
displayName: 'Response Content-Type',
@@ -355,26 +357,35 @@ export class Webhook implements INodeType {
return new Promise((resolve, reject) => {
form.parse(req, async (err, data, files) => {
- const returnData: INodeExecutionData[] = this.helpers.returnJsonArray({
- body: data,
- headers,
- query: this.getQueryData(),
- });
+ const returnItem: INodeExecutionData = {
+ binary: {},
+ json: {
+ body: this.getBodyData(),
+ headers,
+ query: this.getQueryData(),
+ },
+ };
+
+ let count = 0;
for (const file of Object.keys(files)) {
+
+ let binaryPropertyName = file;
+ if (options.binaryPropertyName) {
+ binaryPropertyName = `${options.binaryPropertyName}${count}`;
+ }
+
const fileJson = files[file].toJSON() as IDataObject;
- const [fileName, fileExtension] = (fileJson.name as string).split('.');
const fileContent = await fs.promises.readFile(files[file].path);
- const buffer = Buffer.from(fileContent);
- set(returnData[0], `binary[${fileName}]`, {
- data: buffer.toString(BINARY_ENCODING),
- mimeType: fileJson.type,
- fileName: fileJson.name,
- fileExtension,
- });
+
+ returnItem.binary![binaryPropertyName] = await this.helpers.prepareBinaryData(Buffer.from(fileContent), fileJson.name as string, fileJson.type as string);
+
+ count += 1;
}
resolve({
workflowData: [
- returnData,
+ [
+ returnItem,
+ ]
],
});
});