From f4c92c3602c2c02e74939f07222616ac14c6f1e2 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 18:40:34 +0100 Subject: [PATCH 01/25] Update node airtable --- packages/nodes-base/nodes/Airtable/GenericFunctions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts index e85d1867f366f..a3d91a695228d 100644 --- a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts @@ -127,7 +127,7 @@ export async function downloadRecordAttachments(this: IExecuteFunctions | IPollF for (const [index, attachment] of (record.fields[fieldName] as IAttachment[]).entries()) { const file = await apiRequest.call(this, 'GET', '', {}, {}, attachment.url, { json: false, encoding: null }); element.binary![`${fieldName}_${index}`] = { - data: Buffer.from(file).toString('base64'), + data: await this.helpers.prepareBinaryData(Buffer.from(file), attachment.filename), fileName: attachment.filename, mimeType: attachment.type, }; From e394929d166b9f65b56f022853507664bc1e367e Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 18:43:50 +0100 Subject: [PATCH 02/25] Update nodenextcloud --- packages/nodes-base/nodes/NextCloud/NextCloud.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts index 538f14cebbf23..046e737270459 100644 --- a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts +++ b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts @@ -1066,7 +1066,7 @@ export class NextCloud implements INodeType { throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`); } - body = Buffer.from(item.binary[propertyNameUpload].data, BINARY_ENCODING); + body = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload); } else { // Is text file body = this.getNodeParameter('fileContent', i) as string; From 34fa6690fbb0599ce01f183a1f54f3e36224c9e0 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 19:27:37 +0100 Subject: [PATCH 03/25] Update node spreadsheet --- .../nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts b/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts index 5b70b3e39b8f0..43e40c7f327e5 100644 --- a/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts +++ b/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts @@ -346,7 +346,7 @@ export class SpreadsheetFile implements INodeType { } // Read the binary spreadsheet data - const binaryData = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING); + const binaryData = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); let workbook; if (options.readAsString === true) { workbook = xlsxRead(binaryData.toString(), { type: 'string', raw: options.rawData as boolean }); From 1335f00cae4d255413f9de8ec3986bcb2622aa53 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 19:35:55 +0100 Subject: [PATCH 04/25] Update node cortex, dropbox, editImage nodes --- packages/nodes-base/nodes/Cortex/Cortex.node.ts | 4 ++-- packages/nodes-base/nodes/Dropbox/Dropbox.node.ts | 2 +- packages/nodes-base/nodes/EditImage/EditImage.node.ts | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/nodes/Cortex/Cortex.node.ts b/packages/nodes-base/nodes/Cortex/Cortex.node.ts index 74d1d8c440988..bfb9df5632612 100644 --- a/packages/nodes-base/nodes/Cortex/Cortex.node.ts +++ b/packages/nodes-base/nodes/Cortex/Cortex.node.ts @@ -242,7 +242,7 @@ export class Cortex implements INodeType { throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`); } - const fileBufferData = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING); + const fileBufferData = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); const options = { formData: { @@ -425,7 +425,7 @@ export class Cortex implements INodeType { throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`); } - const fileBufferData = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING); + const fileBufferData = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); const sha256 = createHash('sha256').update(fileBufferData).digest('hex'); (body.data as IDataObject).attachment = { diff --git a/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts b/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts index 2fc0c5a2645e2..fe6524f4f2680 100644 --- a/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts +++ b/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts @@ -859,7 +859,7 @@ export class Dropbox implements INodeType { throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`); } - body = Buffer.from(item.binary[propertyNameUpload].data, BINARY_ENCODING); + body = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload); } else { // Is text file body = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8'); diff --git a/packages/nodes-base/nodes/EditImage/EditImage.node.ts b/packages/nodes-base/nodes/EditImage/EditImage.node.ts index 1326aa7ed3cda..b50b342216edc 100644 --- a/packages/nodes-base/nodes/EditImage/EditImage.node.ts +++ b/packages/nodes-base/nodes/EditImage/EditImage.node.ts @@ -1179,7 +1179,8 @@ export class EditImage implements INodeType { throw new NodeOperationError(this.getNode(), `Item does not contain any binary data with the name "${dataPropertyName}".`); } - gmInstance = gm(Buffer.from(item.binary![dataPropertyName as string].data, BINARY_ENCODING)); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, dataPropertyName); + gmInstance = gm(binaryDataBuffer); gmInstance = gmInstance.background('transparent'); } @@ -1218,7 +1219,8 @@ export class EditImage implements INodeType { const { fd, path, cleanup } = await file(); cleanupFunctions.push(cleanup); - await fsWriteFileAsync(fd, Buffer.from(item.binary![operationData.dataPropertyNameComposite as string].data, BINARY_ENCODING)); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, operationData.dataPropertyNameComposite as string); + await fsWriteFileAsync(fd, binaryDataBuffer); if (operations[0].operation === 'create') { // It seems like if the image gets created newly we have to create a new gm instance From a222d74aca7f7c59ef6da7c0ae2a7e1de58a1c89 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 19:40:41 +0100 Subject: [PATCH 05/25] Update node emailSend --- packages/nodes-base/nodes/EmailSend/EmailSend.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts b/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts index 999f63b7c30a6..abbdb7ccc6c7b 100644 --- a/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts +++ b/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts @@ -198,7 +198,7 @@ export class EmailSend implements INodeType { } attachments.push({ filename: item.binary[propertyName].fileName || 'unknown', - content: Buffer.from(item.binary[propertyName].data, BINARY_ENCODING), + content: await this.helpers.getBinaryDataBuffer(itemIndex, propertyName), }); } From def81939c7f02a9c43972826e496ab2d383562b2 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 19:41:52 +0100 Subject: [PATCH 06/25] Update node ftp --- packages/nodes-base/nodes/Ftp/Ftp.node.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/nodes/Ftp/Ftp.node.ts b/packages/nodes-base/nodes/Ftp/Ftp.node.ts index 78f34f3864217..71affeca36403 100644 --- a/packages/nodes-base/nodes/Ftp/Ftp.node.ts +++ b/packages/nodes-base/nodes/Ftp/Ftp.node.ts @@ -503,7 +503,7 @@ export class Ftp implements INodeType { throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`); } - const buffer = Buffer.from(item.binary[propertyNameUpload].data, BINARY_ENCODING) as Buffer; + const buffer = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload); await sftp!.put(buffer, remotePath); } else { // Is text file @@ -597,7 +597,7 @@ export class Ftp implements INodeType { throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`); } - const buffer = Buffer.from(item.binary[propertyNameUpload].data, BINARY_ENCODING) as Buffer; + const buffer = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload); try { await ftp!.put(buffer, remotePath); From d9b1c8c2efe447d9780c6daee2f5540ae546bb6d Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 19:42:53 +0100 Subject: [PATCH 07/25] Update node googleDrive --- packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts index 522c6a4462bd5..b54cc32b426db 100644 --- a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts +++ b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts @@ -2423,7 +2423,7 @@ export class GoogleDrive implements INodeType { originalFilename = item.binary[propertyNameUpload].fileName; } - body = Buffer.from(item.binary[propertyNameUpload].data, BINARY_ENCODING); + body = this.helpers.getBinaryDataBuffer(i, propertyNameUpload); } else { // Is text file body = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8'); From 7122612271f73bd04db798980f283ae3f519c40b Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 19:43:35 +0100 Subject: [PATCH 08/25] Update node googleDrive fix --- packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts index b54cc32b426db..73bcf92c80c21 100644 --- a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts +++ b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts @@ -2423,7 +2423,7 @@ export class GoogleDrive implements INodeType { originalFilename = item.binary[propertyNameUpload].fileName; } - body = this.helpers.getBinaryDataBuffer(i, propertyNameUpload); + body = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload); } else { // Is text file body = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8'); From 643b974bc5172a00295ad2dd61b2b1543b1c546a Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 19:44:49 +0100 Subject: [PATCH 09/25] Update node youtube --- packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts b/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts index c5c1a2a38a7a4..6617dc8e0174a 100644 --- a/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts +++ b/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts @@ -426,7 +426,7 @@ export class YouTube implements INodeType { mimeType = item.binary[binaryProperty].mimeType; } - const body = Buffer.from(item.binary[binaryProperty].data, BINARY_ENCODING); + const body = await this.helpers.getBinaryDataBuffer(i, binaryProperty); const requestOptions = { headers: { @@ -913,7 +913,7 @@ export class YouTube implements INodeType { mimeType = item.binary[binaryProperty].mimeType; } - const body = Buffer.from(item.binary[binaryProperty].data, BINARY_ENCODING); + const body = await this.helpers.getBinaryDataBuffer(i, binaryProperty); const requestOptions = { headers: { From fcb39013eab17663922fe8da09df45b7594caedb Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 19:47:34 +0100 Subject: [PATCH 10/25] Update node htmlExtract --- packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts b/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts index 78cb0749b11ac..d3d2f1900cd4c 100644 --- a/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts +++ b/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts @@ -240,7 +240,9 @@ export class HtmlExtract implements INodeType { if (item.binary[dataPropertyName] === undefined) { throw new NodeOperationError(this.getNode(), `No property named "${dataPropertyName}" exists!`); } - htmlArray = Buffer.from(item.binary[dataPropertyName].data, 'base64').toString('utf8'); + + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, dataPropertyName); + htmlArray = binaryDataBuffer.toString('utf-8'); } // Convert it always to array that it works with a string or an array of strings From cdcb18e0118e8260c29adac246eac7a6b6085d48 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 19:48:57 +0100 Subject: [PATCH 11/25] Update node linkedIn --- packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts b/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts index 58a7e2a6ba556..0bba06369a7af 100644 --- a/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts +++ b/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts @@ -149,7 +149,7 @@ export class LinkedIn implements INodeType { } // Buffer binary data - const buffer = Buffer.from(item.binary[propertyNameUpload].data, BINARY_ENCODING) as Buffer; + const buffer = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload); // Upload image await linkedInApiRequest.call(this, 'POST', uploadUrl, buffer, true); From 9d6cc0a15e1799b60fccbf425a4bf8692502e902 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 19:50:43 +0100 Subject: [PATCH 12/25] Update node mailgun --- packages/nodes-base/nodes/Mailgun/Mailgun.node.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts b/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts index a2d35e9277364..7ce97994f3431 100644 --- a/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts +++ b/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts @@ -158,8 +158,9 @@ export class Mailgun implements INodeType { if (!item.binary.hasOwnProperty(propertyName)) { continue; } + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, propertyName); attachments.push({ - value: Buffer.from(item.binary[propertyName].data, BINARY_ENCODING), + value: binaryDataBuffer, options: { filename: item.binary[propertyName].fileName || 'unknown', From d9c79bcc44af29d5581f1b6ae99aaf5324dfdb88 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 19:59:17 +0100 Subject: [PATCH 13/25] Update node matrix --- packages/nodes-base/nodes/Matrix/GenericFunctions.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts index 1db691ab237f5..1143046edbe0b 100644 --- a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts @@ -69,7 +69,7 @@ export async function matrixApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function handleMatrixCall(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, item: IDataObject, index: number, resource: string, operation: string): Promise { // tslint:disable-line:no-any +export async function handleMatrixCall(this: IExecuteFunctions, item: IDataObject, index: number, resource: string, operation: string): Promise { // tslint:disable-line:no-any if (resource === 'account') { if (operation === 'me') { @@ -193,13 +193,12 @@ export async function handleMatrixCall(this: IExecuteFunctions | IExecuteSingleF throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`); } - //@ts-ignore + // @ts-ignore qs.filename = item.binary[binaryPropertyName].fileName; //@ts-ignore filename = item.binary[binaryPropertyName].fileName; - //@ts-ignore - body = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING); + body = await this.helpers.getBinaryDataBuffer(index, binaryPropertyName); //@ts-ignore headers['Content-Type'] = item.binary[binaryPropertyName].mimeType; headers['accept'] = 'application/json,text/*;q=0.99'; From 0fd251266ec347d8f526aabef492e1cfb7bd7e65 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 19:59:33 +0100 Subject: [PATCH 14/25] Update node pipedrive --- packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts index 8fc2154dfed13..dfc075a2f2bed 100644 --- a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts @@ -4500,7 +4500,7 @@ export class Pipedrive implements INodeType { throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`); } - const fileBufferData = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING); + const fileBufferData = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); formData.file = { value: fileBufferData, From b5ae3625137f88146418af885d29aa87c87ff81c Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 20:00:33 +0100 Subject: [PATCH 15/25] Update node readPdf --- packages/nodes-base/nodes/ReadPdf/ReadPdf.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/ReadPdf/ReadPdf.node.ts b/packages/nodes-base/nodes/ReadPdf/ReadPdf.node.ts index fbef80a90fef4..a08f405524b1d 100644 --- a/packages/nodes-base/nodes/ReadPdf/ReadPdf.node.ts +++ b/packages/nodes-base/nodes/ReadPdf/ReadPdf.node.ts @@ -55,7 +55,7 @@ export class ReadPdf implements INodeType { item.binary = {}; } - const binaryData = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING); + const binaryData = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName); returnData.push({ binary: item.binary, json: await pdf(binaryData), From f7672102a8a529a6679d29e65af3c2eb26b74c8f Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 20:35:22 +0100 Subject: [PATCH 16/25] Update node facebookGraphApi --- packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts b/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts index 9716003b48117..2600df71a79d5 100644 --- a/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts +++ b/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts @@ -391,9 +391,10 @@ export class FacebookGraphApi implements INodeType { const binaryProperty = item.binary[binaryPropertyName] as IBinaryData; + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName); requestOptions.formData = { [propertyName]: { - value: Buffer.from(binaryProperty.data, BINARY_ENCODING), + value: binaryDataBuffer, options: { filename: binaryProperty.fileName, contentType: binaryProperty.mimeType, From 7c69476a920acaac64fcf3e6559f3ae5e7e0d6f0 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 20:39:29 +0100 Subject: [PATCH 17/25] Update node httpRequest --- packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts b/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts index b6826022cdb50..24c62fcfd9058 100644 --- a/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts @@ -771,8 +771,9 @@ export class HttpRequest implements INodeType { if (item.binary[binaryPropertyName] === undefined) { throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`); } - const binaryProperty = item.binary[binaryPropertyName] as IBinaryData; - requestOptions.body = Buffer.from(binaryProperty.data, BINARY_ENCODING); + + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName); + requestOptions.body = binaryDataBuffer; } else if (options.bodyContentType === 'multipart-form-data') { requestOptions.body = {}; const binaryPropertyNameFull = this.getNodeParameter('binaryPropertyName', itemIndex) as string; @@ -794,9 +795,10 @@ export class HttpRequest implements INodeType { } const binaryProperty = item.binary[binaryPropertyName] as IBinaryData; + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName); requestOptions.body[propertyName] = { - value: Buffer.from(binaryProperty.data, BINARY_ENCODING), + value: binaryDataBuffer, options: { filename: binaryProperty.fileName, contentType: binaryProperty.mimeType, From 403b6b073b150ba669731c3f602410cec8590ae1 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 20:42:51 +0100 Subject: [PATCH 18/25] Update node nocoDB --- packages/nodes-base/nodes/NocoDB/GenericFunctions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts index b47ea6fb84163..caad3618e723b 100644 --- a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts @@ -119,7 +119,7 @@ export async function downloadRecordAttachments(this: IExecuteFunctions | IPollF for (const [index, attachment] of (JSON.parse(record[fieldName] as string) as IAttachment[]).entries()) { const file = await apiRequest.call(this, 'GET', '', {}, {}, attachment.url, { json: false, encoding: null }); element.binary![`${fieldName}_${index}`] = { - data: Buffer.from(file).toString('base64'), + data: await this.helpers.prepareBinaryData(Buffer.from(file), attachment.title), fileName: attachment.title, mimeType: attachment.mimetype, }; From a4b1e359670b5b5452b17ce86b09cd745f2352d0 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 20:50:35 +0100 Subject: [PATCH 19/25] Update node httpRequest, respondToWebhook --- packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts | 1 - .../nodes/RespondToWebhook/RespondToWebhook.node.ts | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts b/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts index 24c62fcfd9058..7ad64d59b7536 100644 --- a/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts @@ -1,5 +1,4 @@ import { - BINARY_ENCODING, IExecuteFunctions, } from 'n8n-core'; import { diff --git a/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts b/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts index 42467967cc96a..d73cddcd4c551 100644 --- a/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts +++ b/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts @@ -1,10 +1,9 @@ import { - BINARY_ENCODING, + IExecuteFunctions, } from 'n8n-core'; import { IDataObject, - IExecuteFunctions, IN8nHttpFullResponse, IN8nHttpResponse, INodeExecutionData, @@ -202,7 +201,7 @@ export class RespondToWebhook implements INodeType { ], }; - execute(this: IExecuteFunctions): Promise { + async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const respondWith = this.getNodeParameter('respondWith', 0) as string; @@ -250,6 +249,7 @@ export class RespondToWebhook implements INodeType { } const binaryData = item.binary[responseBinaryPropertyName]; + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(0, responseBinaryPropertyName); if (binaryData === undefined) { throw new NodeOperationError(this.getNode(), `No binary data property "${responseBinaryPropertyName}" does not exists on item!`); @@ -258,7 +258,7 @@ export class RespondToWebhook implements INodeType { if (headers['content-type']) { headers['content-type'] = binaryData.mimeType; } - responseBody = Buffer.from(binaryData.data, BINARY_ENCODING); + responseBody = binaryDataBuffer; } else if (respondWith !== 'noData') { throw new NodeOperationError(this.getNode(), `The Response Data option "${respondWith}" is not supported!`); } From 4469ce16c7f7fc9ceaaaa1bb9d384d9adbeb30d5 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 20:52:06 +0100 Subject: [PATCH 20/25] Update node signi4 --- packages/nodes-base/nodes/Signl4/Signl4.node.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Signl4/Signl4.node.ts b/packages/nodes-base/nodes/Signl4/Signl4.node.ts index 5691763a88ea0..3b7d6222ebcee 100644 --- a/packages/nodes-base/nodes/Signl4/Signl4.node.ts +++ b/packages/nodes-base/nodes/Signl4/Signl4.node.ts @@ -312,8 +312,9 @@ export class Signl4 implements INodeType { throw new NodeOperationError(this.getNode(), `Invalid extension, just ${supportedFileExtension.join(',')} are supported}`); } + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, propertyName); data.attachment = { - value: Buffer.from(binaryProperty.data, BINARY_ENCODING), + value: binaryDataBuffer, options: { filename: binaryProperty.fileName, contentType: binaryProperty.mimeType, From 5641ef4be06a8f8ca6c9d9c7e177a0532c1e9186 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 20:53:12 +0100 Subject: [PATCH 21/25] Update node slack --- packages/nodes-base/nodes/Slack/Slack.node.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Slack/Slack.node.ts b/packages/nodes-base/nodes/Slack/Slack.node.ts index 14256178a44c3..5df0ab2caf788 100644 --- a/packages/nodes-base/nodes/Slack/Slack.node.ts +++ b/packages/nodes-base/nodes/Slack/Slack.node.ts @@ -977,9 +977,10 @@ export class Slack implements INodeType { || items[i].binary[binaryPropertyName] === undefined) { throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`); } + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); body.file = { //@ts-ignore - value: Buffer.from(items[i].binary[binaryPropertyName].data, BINARY_ENCODING), + value: binaryDataBuffer, options: { //@ts-ignore filename: items[i].binary[binaryPropertyName].fileName, From 4cccf0c694b76c1cc330f4f5b10e9ae023f28f18 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 20:56:00 +0100 Subject: [PATCH 22/25] Update node zulip --- packages/nodes-base/nodes/Zulip/Zulip.node.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Zulip/Zulip.node.ts b/packages/nodes-base/nodes/Zulip/Zulip.node.ts index 67489c82ec6da..2da9d9e50c12e 100644 --- a/packages/nodes-base/nodes/Zulip/Zulip.node.ts +++ b/packages/nodes-base/nodes/Zulip/Zulip.node.ts @@ -217,10 +217,12 @@ export class Zulip implements INodeType { if (items[i].binary[binaryProperty] === undefined) { throw new NodeOperationError(this.getNode(), `No binary data property "${binaryProperty}" does not exists on item!`); } + + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); const formData = { file: { //@ts-ignore - value: Buffer.from(items[i].binary[binaryProperty].data, BINARY_ENCODING), + value: binaryDataBuffer, options: { //@ts-ignore filename: items[i].binary[binaryProperty].fileName, From ecf3aff85195ee339626fa89e8cc6cbbc98effb4 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 21:07:06 +0100 Subject: [PATCH 23/25] cleanup --- packages/nodes-base/nodes/Cortex/Cortex.node.ts | 1 - packages/nodes-base/nodes/Dropbox/Dropbox.node.ts | 5 +---- .../nodes-base/nodes/EmailSend/EmailSend.node.ts | 5 +---- .../nodes/Facebook/FacebookGraphApi.node.ts | 5 +---- packages/nodes-base/nodes/Ftp/Ftp.node.ts | 5 +---- .../nodes/Google/Drive/GoogleDrive.node.ts | 5 +---- .../nodes-base/nodes/Google/YouTube/YouTube.node.ts | 5 +---- packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts | 5 +---- packages/nodes-base/nodes/Mailgun/Mailgun.node.ts | 5 +---- .../nodes-base/nodes/Matrix/GenericFunctions.ts | 1 - .../nodes-base/nodes/NextCloud/NextCloud.node.ts | 5 +---- .../nodes-base/nodes/Pipedrive/Pipedrive.node.ts | 1 - packages/nodes-base/nodes/ReadPdf/ReadPdf.node.ts | 5 +---- packages/nodes-base/nodes/S3/S3.node.ts | 13 +++---------- packages/nodes-base/nodes/SendGrid/SendGrid.node.ts | 5 +---- packages/nodes-base/nodes/Signl4/Signl4.node.ts | 5 +---- packages/nodes-base/nodes/Slack/Slack.node.ts | 5 +---- .../nodes/SpreadsheetFile/SpreadsheetFile.node.ts | 5 +---- .../nodes-base/nodes/Telegram/GenericFunctions.ts | 1 - packages/nodes-base/nodes/Wait/Wait.node.ts | 1 + packages/nodes-base/nodes/Zulip/Zulip.node.ts | 1 - 21 files changed, 18 insertions(+), 71 deletions(-) diff --git a/packages/nodes-base/nodes/Cortex/Cortex.node.ts b/packages/nodes-base/nodes/Cortex/Cortex.node.ts index bfb9df5632612..dfe25d1e00db6 100644 --- a/packages/nodes-base/nodes/Cortex/Cortex.node.ts +++ b/packages/nodes-base/nodes/Cortex/Cortex.node.ts @@ -1,5 +1,4 @@ import { - BINARY_ENCODING, IExecuteFunctions, } from 'n8n-core'; diff --git a/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts b/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts index fe6524f4f2680..41a6e54b11aa4 100644 --- a/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts +++ b/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, diff --git a/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts b/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts index abbdb7ccc6c7b..a6abae2159e89 100644 --- a/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts +++ b/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, INodeExecutionData, diff --git a/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts b/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts index 2600df71a79d5..21984cc35216d 100644 --- a/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts +++ b/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryData, IDataObject, diff --git a/packages/nodes-base/nodes/Ftp/Ftp.node.ts b/packages/nodes-base/nodes/Ftp/Ftp.node.ts index 71affeca36403..c373bb17bf780 100644 --- a/packages/nodes-base/nodes/Ftp/Ftp.node.ts +++ b/packages/nodes-base/nodes/Ftp/Ftp.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, IDataObject, diff --git a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts index 73bcf92c80c21..45bf35f725c73 100644 --- a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts +++ b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, diff --git a/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts b/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts index 6617dc8e0174a..29bcad1722d33 100644 --- a/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts +++ b/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, diff --git a/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts b/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts index 0bba06369a7af..80cb1a875da68 100644 --- a/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts +++ b/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, ILoadOptionsFunctions, diff --git a/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts b/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts index 7ce97994f3431..f2ce0d753de7f 100644 --- a/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts +++ b/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, INodeExecutionData, diff --git a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts index 1143046edbe0b..3293aff87dd1a 100644 --- a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts @@ -5,7 +5,6 @@ import { import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; import { - BINARY_ENCODING, IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions, diff --git a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts index 046e737270459..c916c99213a0f 100644 --- a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts +++ b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, diff --git a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts index dfc075a2f2bed..d565080aa4a2b 100644 --- a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts @@ -1,5 +1,4 @@ import { - BINARY_ENCODING, IExecuteFunctions, ILoadOptionsFunctions, } from 'n8n-core'; diff --git a/packages/nodes-base/nodes/ReadPdf/ReadPdf.node.ts b/packages/nodes-base/nodes/ReadPdf/ReadPdf.node.ts index a08f405524b1d..7ca735d5472c8 100644 --- a/packages/nodes-base/nodes/ReadPdf/ReadPdf.node.ts +++ b/packages/nodes-base/nodes/ReadPdf/ReadPdf.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { INodeExecutionData, diff --git a/packages/nodes-base/nodes/S3/S3.node.ts b/packages/nodes-base/nodes/S3/S3.node.ts index 5f33fca1c878d..72bfb8db0ccf8 100644 --- a/packages/nodes-base/nodes/S3/S3.node.ts +++ b/packages/nodes-base/nodes/S3/S3.node.ts @@ -3,18 +3,11 @@ import { snakeCase, } from 'change-case'; -import { - createHash, -} from 'crypto'; +import { createHash } from 'crypto'; -import { - Builder, -} from 'xml2js'; +import { Builder } from 'xml2js'; -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, diff --git a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts index fc9f1f8ce2731..1d843a5f15691 100644 --- a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts +++ b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, diff --git a/packages/nodes-base/nodes/Signl4/Signl4.node.ts b/packages/nodes-base/nodes/Signl4/Signl4.node.ts index 3b7d6222ebcee..d7a46663d3348 100644 --- a/packages/nodes-base/nodes/Signl4/Signl4.node.ts +++ b/packages/nodes-base/nodes/Signl4/Signl4.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, diff --git a/packages/nodes-base/nodes/Slack/Slack.node.ts b/packages/nodes-base/nodes/Slack/Slack.node.ts index 5df0ab2caf788..c36ff8908fbc1 100644 --- a/packages/nodes-base/nodes/Slack/Slack.node.ts +++ b/packages/nodes-base/nodes/Slack/Slack.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, diff --git a/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts b/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts index 43e40c7f327e5..9b6ea32dfbd93 100644 --- a/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts +++ b/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, diff --git a/packages/nodes-base/nodes/Telegram/GenericFunctions.ts b/packages/nodes-base/nodes/Telegram/GenericFunctions.ts index 4ed4eec279513..e1bce013e5839 100644 --- a/packages/nodes-base/nodes/Telegram/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Telegram/GenericFunctions.ts @@ -1,5 +1,4 @@ import { - BINARY_ENCODING, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, diff --git a/packages/nodes-base/nodes/Wait/Wait.node.ts b/packages/nodes-base/nodes/Wait/Wait.node.ts index accc79f94d1e0..20280377bd091 100644 --- a/packages/nodes-base/nodes/Wait/Wait.node.ts +++ b/packages/nodes-base/nodes/Wait/Wait.node.ts @@ -1,4 +1,5 @@ import { + BINARY_ENCODING, IExecuteFunctions, WAIT_TIME_UNLIMITED, } from 'n8n-core'; diff --git a/packages/nodes-base/nodes/Zulip/Zulip.node.ts b/packages/nodes-base/nodes/Zulip/Zulip.node.ts index 2da9d9e50c12e..6f5d945c9469d 100644 --- a/packages/nodes-base/nodes/Zulip/Zulip.node.ts +++ b/packages/nodes-base/nodes/Zulip/Zulip.node.ts @@ -1,5 +1,4 @@ import { - BINARY_ENCODING, IExecuteFunctions, } from 'n8n-core'; import { From c26c05479d7f44e55907efac773d5a1dfa591979 Mon Sep 17 00:00:00 2001 From: ahsan-virani Date: Mon, 3 Jan 2022 21:54:51 +0100 Subject: [PATCH 24/25] fix generic funcs --- packages/nodes-base/nodes/Airtable/GenericFunctions.ts | 7 ++----- packages/nodes-base/nodes/NocoDB/GenericFunctions.ts | 6 +----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts index a3d91a695228d..a447d0a17604d 100644 --- a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts @@ -122,15 +122,12 @@ export async function downloadRecordAttachments(this: IExecuteFunctions | IPollF for (const record of records) { const element: INodeExecutionData = { json: {}, binary: {} }; element.json = record as unknown as IDataObject; + console.log(record.fields); for (const fieldName of fieldNames) { if (record.fields[fieldName] !== undefined) { for (const [index, attachment] of (record.fields[fieldName] as IAttachment[]).entries()) { const file = await apiRequest.call(this, 'GET', '', {}, {}, attachment.url, { json: false, encoding: null }); - element.binary![`${fieldName}_${index}`] = { - data: await this.helpers.prepareBinaryData(Buffer.from(file), attachment.filename), - fileName: attachment.filename, - mimeType: attachment.type, - }; + element.binary![`${fieldName}_${index}`] = await this.helpers.prepareBinaryData(Buffer.from(file), attachment.filename, attachment.type); } } } diff --git a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts index caad3618e723b..b4c6720640fc5 100644 --- a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts @@ -118,11 +118,7 @@ export async function downloadRecordAttachments(this: IExecuteFunctions | IPollF if (record[fieldName]) { for (const [index, attachment] of (JSON.parse(record[fieldName] as string) as IAttachment[]).entries()) { const file = await apiRequest.call(this, 'GET', '', {}, {}, attachment.url, { json: false, encoding: null }); - element.binary![`${fieldName}_${index}`] = { - data: await this.helpers.prepareBinaryData(Buffer.from(file), attachment.title), - fileName: attachment.title, - mimeType: attachment.mimetype, - }; + element.binary![`${fieldName}_${index}`] = await this.helpers.prepareBinaryData(Buffer.from(file), attachment.title, attachment.mimetype); } } } From 910de23295c746472afd955acd4133079f4ccd14 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Mon, 3 Jan 2022 22:34:02 +0100 Subject: [PATCH 25/25] :bug: Fix EditImage Node --- packages/nodes-base/nodes/Airtable/GenericFunctions.ts | 1 - packages/nodes-base/nodes/EditImage/EditImage.node.ts | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts index a447d0a17604d..970e9323c792b 100644 --- a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts @@ -122,7 +122,6 @@ export async function downloadRecordAttachments(this: IExecuteFunctions | IPollF for (const record of records) { const element: INodeExecutionData = { json: {}, binary: {} }; element.json = record as unknown as IDataObject; - console.log(record.fields); for (const fieldName of fieldNames) { if (record.fields[fieldName] !== undefined) { for (const [index, attachment] of (record.fields[fieldName] as IAttachment[]).entries()) { diff --git a/packages/nodes-base/nodes/EditImage/EditImage.node.ts b/packages/nodes-base/nodes/EditImage/EditImage.node.ts index b50b342216edc..136447f794d44 100644 --- a/packages/nodes-base/nodes/EditImage/EditImage.node.ts +++ b/packages/nodes-base/nodes/EditImage/EditImage.node.ts @@ -1351,14 +1351,14 @@ export class EditImage implements INodeType { returnData.push(await (new Promise((resolve, reject) => { gmInstance - .toBuffer((error: Error | null, buffer: Buffer) => { + .toBuffer(async (error: Error | null, buffer: Buffer) => { cleanupFunctions.forEach(async cleanup => await cleanup()); if (error) { return reject(error); } - newItem.binary![dataPropertyName as string].data = buffer.toString(BINARY_ENCODING); + newItem.binary![dataPropertyName as string].data = (await this.helpers.prepareBinaryData(Buffer.from(buffer))).data; return resolve(newItem); });