mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 04:47:29 -08:00
🐛 Binary data handling fixes (#2629)
* Update node airtable
* Update nodenextcloud
* Update node spreadsheet
* Update node cortex, dropbox, editImage nodes
* Update node emailSend
* Update node ftp
* Update node googleDrive
* Update node googleDrive fix
* Update node youtube
* Update node htmlExtract
* Update node linkedIn
* Update node mailgun
* Update node matrix
* Update node pipedrive
* Update node readPdf
* Update node facebookGraphApi
* Update node httpRequest
* Update node nocoDB
* Update node httpRequest, respondToWebhook
* Update node signi4
* Update node slack
* Update node zulip
* cleanup
* fix generic funcs
* 🐛 Fix EditImage Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
parent
aff93480d4
commit
224ef736de
|
@ -126,11 +126,7 @@ export async function downloadRecordAttachments(this: IExecuteFunctions | IPollF
|
||||||
if (record.fields[fieldName] !== undefined) {
|
if (record.fields[fieldName] !== undefined) {
|
||||||
for (const [index, attachment] of (record.fields[fieldName] as IAttachment[]).entries()) {
|
for (const [index, attachment] of (record.fields[fieldName] as IAttachment[]).entries()) {
|
||||||
const file = await apiRequest.call(this, 'GET', '', {}, {}, attachment.url, { json: false, encoding: null });
|
const file = await apiRequest.call(this, 'GET', '', {}, {}, attachment.url, { json: false, encoding: null });
|
||||||
element.binary![`${fieldName}_${index}`] = {
|
element.binary![`${fieldName}_${index}`] = await this.helpers.prepareBinaryData(Buffer.from(file), attachment.filename, attachment.type);
|
||||||
data: Buffer.from(file).toString('base64'),
|
|
||||||
fileName: attachment.filename,
|
|
||||||
mimeType: attachment.type,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import {
|
import {
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
|
@ -242,7 +241,7 @@ export class Cortex implements INodeType {
|
||||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
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 = {
|
const options = {
|
||||||
formData: {
|
formData: {
|
||||||
|
@ -425,7 +424,7 @@ export class Cortex implements INodeType {
|
||||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
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');
|
const sha256 = createHash('sha256').update(fileBufferData).digest('hex');
|
||||||
|
|
||||||
(body.data as IDataObject).attachment = {
|
(body.data as IDataObject).attachment = {
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
|
||||||
} from 'n8n-core';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
|
@ -859,7 +856,7 @@ export class Dropbox implements INodeType {
|
||||||
throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`);
|
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 {
|
} else {
|
||||||
// Is text file
|
// Is text file
|
||||||
body = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8');
|
body = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8');
|
||||||
|
|
|
@ -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}".`);
|
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');
|
gmInstance = gmInstance.background('transparent');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,7 +1219,8 @@ export class EditImage implements INodeType {
|
||||||
|
|
||||||
const { fd, path, cleanup } = await file();
|
const { fd, path, cleanup } = await file();
|
||||||
cleanupFunctions.push(cleanup);
|
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') {
|
if (operations[0].operation === 'create') {
|
||||||
// It seems like if the image gets created newly we have to create a new gm instance
|
// It seems like if the image gets created newly we have to create a new gm instance
|
||||||
|
@ -1349,14 +1351,14 @@ export class EditImage implements INodeType {
|
||||||
|
|
||||||
returnData.push(await (new Promise<INodeExecutionData>((resolve, reject) => {
|
returnData.push(await (new Promise<INodeExecutionData>((resolve, reject) => {
|
||||||
gmInstance
|
gmInstance
|
||||||
.toBuffer((error: Error | null, buffer: Buffer) => {
|
.toBuffer(async (error: Error | null, buffer: Buffer) => {
|
||||||
cleanupFunctions.forEach(async cleanup => await cleanup());
|
cleanupFunctions.forEach(async cleanup => await cleanup());
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return reject(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);
|
return resolve(newItem);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions
|
|
||||||
} from 'n8n-core';
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
|
@ -198,7 +195,7 @@ export class EmailSend implements INodeType {
|
||||||
}
|
}
|
||||||
attachments.push({
|
attachments.push({
|
||||||
filename: item.binary[propertyName].fileName || 'unknown',
|
filename: item.binary[propertyName].fileName || 'unknown',
|
||||||
content: Buffer.from(item.binary[propertyName].data, BINARY_ENCODING),
|
content: await this.helpers.getBinaryDataBuffer(itemIndex, propertyName),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
|
||||||
} from 'n8n-core';
|
|
||||||
import {
|
import {
|
||||||
IBinaryData,
|
IBinaryData,
|
||||||
IDataObject,
|
IDataObject,
|
||||||
|
@ -391,9 +388,10 @@ export class FacebookGraphApi implements INodeType {
|
||||||
|
|
||||||
const binaryProperty = item.binary[binaryPropertyName] as IBinaryData;
|
const binaryProperty = item.binary[binaryPropertyName] as IBinaryData;
|
||||||
|
|
||||||
|
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);
|
||||||
requestOptions.formData = {
|
requestOptions.formData = {
|
||||||
[propertyName]: {
|
[propertyName]: {
|
||||||
value: Buffer.from(binaryProperty.data, BINARY_ENCODING),
|
value: binaryDataBuffer,
|
||||||
options: {
|
options: {
|
||||||
filename: binaryProperty.fileName,
|
filename: binaryProperty.fileName,
|
||||||
contentType: binaryProperty.mimeType,
|
contentType: binaryProperty.mimeType,
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions
|
|
||||||
} from 'n8n-core';
|
|
||||||
import {
|
import {
|
||||||
ICredentialDataDecryptedObject,
|
ICredentialDataDecryptedObject,
|
||||||
IDataObject,
|
IDataObject,
|
||||||
|
@ -503,7 +500,7 @@ export class Ftp implements INodeType {
|
||||||
throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`);
|
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);
|
await sftp!.put(buffer, remotePath);
|
||||||
} else {
|
} else {
|
||||||
// Is text file
|
// Is text file
|
||||||
|
@ -597,7 +594,7 @@ export class Ftp implements INodeType {
|
||||||
throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`);
|
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 {
|
try {
|
||||||
await ftp!.put(buffer, remotePath);
|
await ftp!.put(buffer, remotePath);
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
|
||||||
} from 'n8n-core';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
|
@ -2423,7 +2420,7 @@ export class GoogleDrive implements INodeType {
|
||||||
originalFilename = item.binary[propertyNameUpload].fileName;
|
originalFilename = item.binary[propertyNameUpload].fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
body = Buffer.from(item.binary[propertyNameUpload].data, BINARY_ENCODING);
|
body = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload);
|
||||||
} else {
|
} else {
|
||||||
// Is text file
|
// Is text file
|
||||||
body = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8');
|
body = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8');
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
|
||||||
} from 'n8n-core';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
|
@ -426,7 +423,7 @@ export class YouTube implements INodeType {
|
||||||
mimeType = item.binary[binaryProperty].mimeType;
|
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 = {
|
const requestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -913,7 +910,7 @@ export class YouTube implements INodeType {
|
||||||
mimeType = item.binary[binaryProperty].mimeType;
|
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 = {
|
const requestOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
@ -240,7 +240,9 @@ export class HtmlExtract implements INodeType {
|
||||||
if (item.binary[dataPropertyName] === undefined) {
|
if (item.binary[dataPropertyName] === undefined) {
|
||||||
throw new NodeOperationError(this.getNode(), `No property named "${dataPropertyName}" exists!`);
|
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
|
// Convert it always to array that it works with a string or an array of strings
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import {
|
import {
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
import {
|
import {
|
||||||
|
@ -771,8 +770,9 @@ export class HttpRequest implements INodeType {
|
||||||
if (item.binary[binaryPropertyName] === undefined) {
|
if (item.binary[binaryPropertyName] === undefined) {
|
||||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
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') {
|
} else if (options.bodyContentType === 'multipart-form-data') {
|
||||||
requestOptions.body = {};
|
requestOptions.body = {};
|
||||||
const binaryPropertyNameFull = this.getNodeParameter('binaryPropertyName', itemIndex) as string;
|
const binaryPropertyNameFull = this.getNodeParameter('binaryPropertyName', itemIndex) as string;
|
||||||
|
@ -794,9 +794,10 @@ export class HttpRequest implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
const binaryProperty = item.binary[binaryPropertyName] as IBinaryData;
|
const binaryProperty = item.binary[binaryPropertyName] as IBinaryData;
|
||||||
|
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);
|
||||||
|
|
||||||
requestOptions.body[propertyName] = {
|
requestOptions.body[propertyName] = {
|
||||||
value: Buffer.from(binaryProperty.data, BINARY_ENCODING),
|
value: binaryDataBuffer,
|
||||||
options: {
|
options: {
|
||||||
filename: binaryProperty.fileName,
|
filename: binaryProperty.fileName,
|
||||||
contentType: binaryProperty.mimeType,
|
contentType: binaryProperty.mimeType,
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
|
||||||
} from 'n8n-core';
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
ILoadOptionsFunctions,
|
ILoadOptionsFunctions,
|
||||||
|
@ -149,7 +146,7 @@ export class LinkedIn implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Buffer binary data
|
// 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
|
// Upload image
|
||||||
await linkedInApiRequest.call(this, 'POST', uploadUrl, buffer, true);
|
await linkedInApiRequest.call(this, 'POST', uploadUrl, buffer, true);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
|
||||||
} from 'n8n-core';
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
|
@ -158,8 +155,9 @@ export class Mailgun implements INodeType {
|
||||||
if (!item.binary.hasOwnProperty(propertyName)) {
|
if (!item.binary.hasOwnProperty(propertyName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, propertyName);
|
||||||
attachments.push({
|
attachments.push({
|
||||||
value: Buffer.from(item.binary[propertyName].data, BINARY_ENCODING),
|
value: binaryDataBuffer,
|
||||||
options: {
|
options: {
|
||||||
filename: item.binary[propertyName].fileName || 'unknown',
|
filename: item.binary[propertyName].fileName || 'unknown',
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import {
|
||||||
import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
|
import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
IExecuteSingleFunctions,
|
IExecuteSingleFunctions,
|
||||||
ILoadOptionsFunctions,
|
ILoadOptionsFunctions,
|
||||||
|
@ -69,7 +68,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<any> { // tslint:disable-line:no-any
|
export async function handleMatrixCall(this: IExecuteFunctions, item: IDataObject, index: number, resource: string, operation: string): Promise<any> { // tslint:disable-line:no-any
|
||||||
|
|
||||||
if (resource === 'account') {
|
if (resource === 'account') {
|
||||||
if (operation === 'me') {
|
if (operation === 'me') {
|
||||||
|
@ -193,13 +192,12 @@ export async function handleMatrixCall(this: IExecuteFunctions | IExecuteSingleF
|
||||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
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;
|
qs.filename = item.binary[binaryPropertyName].fileName;
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
filename = item.binary[binaryPropertyName].fileName;
|
filename = item.binary[binaryPropertyName].fileName;
|
||||||
|
|
||||||
//@ts-ignore
|
body = await this.helpers.getBinaryDataBuffer(index, binaryPropertyName);
|
||||||
body = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING);
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
headers['Content-Type'] = item.binary[binaryPropertyName].mimeType;
|
headers['Content-Type'] = item.binary[binaryPropertyName].mimeType;
|
||||||
headers['accept'] = 'application/json,text/*;q=0.99';
|
headers['accept'] = 'application/json,text/*;q=0.99';
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
|
||||||
} from 'n8n-core';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
|
@ -1066,7 +1063,7 @@ export class NextCloud implements INodeType {
|
||||||
throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`);
|
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 {
|
} else {
|
||||||
// Is text file
|
// Is text file
|
||||||
body = this.getNodeParameter('fileContent', i) as string;
|
body = this.getNodeParameter('fileContent', i) as string;
|
||||||
|
|
|
@ -118,11 +118,7 @@ export async function downloadRecordAttachments(this: IExecuteFunctions | IPollF
|
||||||
if (record[fieldName]) {
|
if (record[fieldName]) {
|
||||||
for (const [index, attachment] of (JSON.parse(record[fieldName] as string) as IAttachment[]).entries()) {
|
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 });
|
const file = await apiRequest.call(this, 'GET', '', {}, {}, attachment.url, { json: false, encoding: null });
|
||||||
element.binary![`${fieldName}_${index}`] = {
|
element.binary![`${fieldName}_${index}`] = await this.helpers.prepareBinaryData(Buffer.from(file), attachment.title, attachment.mimetype);
|
||||||
data: Buffer.from(file).toString('base64'),
|
|
||||||
fileName: attachment.title,
|
|
||||||
mimeType: attachment.mimetype,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import {
|
import {
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
ILoadOptionsFunctions,
|
ILoadOptionsFunctions,
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
@ -4500,7 +4499,7 @@ export class Pipedrive implements INodeType {
|
||||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
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 = {
|
formData.file = {
|
||||||
value: fileBufferData,
|
value: fileBufferData,
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
|
||||||
} from 'n8n-core';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
|
@ -55,7 +52,7 @@ export class ReadPdf implements INodeType {
|
||||||
item.binary = {};
|
item.binary = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const binaryData = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING);
|
const binaryData = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);
|
||||||
returnData.push({
|
returnData.push({
|
||||||
binary: item.binary,
|
binary: item.binary,
|
||||||
json: await pdf(binaryData),
|
json: await pdf(binaryData),
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import {
|
import {
|
||||||
BINARY_ENCODING,
|
IExecuteFunctions,
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
IExecuteFunctions,
|
|
||||||
IN8nHttpFullResponse,
|
IN8nHttpFullResponse,
|
||||||
IN8nHttpResponse,
|
IN8nHttpResponse,
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
|
@ -202,7 +201,7 @@ export class RespondToWebhook implements INodeType {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
const items = this.getInputData();
|
const items = this.getInputData();
|
||||||
|
|
||||||
const respondWith = this.getNodeParameter('respondWith', 0) as string;
|
const respondWith = this.getNodeParameter('respondWith', 0) as string;
|
||||||
|
@ -250,6 +249,7 @@ export class RespondToWebhook implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
const binaryData = item.binary[responseBinaryPropertyName];
|
const binaryData = item.binary[responseBinaryPropertyName];
|
||||||
|
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(0, responseBinaryPropertyName);
|
||||||
|
|
||||||
if (binaryData === undefined) {
|
if (binaryData === undefined) {
|
||||||
throw new NodeOperationError(this.getNode(), `No binary data property "${responseBinaryPropertyName}" does not exists on item!`);
|
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']) {
|
if (headers['content-type']) {
|
||||||
headers['content-type'] = binaryData.mimeType;
|
headers['content-type'] = binaryData.mimeType;
|
||||||
}
|
}
|
||||||
responseBody = Buffer.from(binaryData.data, BINARY_ENCODING);
|
responseBody = binaryDataBuffer;
|
||||||
} else if (respondWith !== 'noData') {
|
} else if (respondWith !== 'noData') {
|
||||||
throw new NodeOperationError(this.getNode(), `The Response Data option "${respondWith}" is not supported!`);
|
throw new NodeOperationError(this.getNode(), `The Response Data option "${respondWith}" is not supported!`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,18 +3,11 @@ import {
|
||||||
snakeCase,
|
snakeCase,
|
||||||
} from 'change-case';
|
} from 'change-case';
|
||||||
|
|
||||||
import {
|
import { createHash } from 'crypto';
|
||||||
createHash,
|
|
||||||
} from 'crypto';
|
|
||||||
|
|
||||||
import {
|
import { Builder } from 'xml2js';
|
||||||
Builder,
|
|
||||||
} from 'xml2js';
|
|
||||||
|
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
|
||||||
} from 'n8n-core';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IBinaryKeyData,
|
IBinaryKeyData,
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
|
||||||
} from 'n8n-core';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
|
||||||
} from 'n8n-core';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IBinaryKeyData,
|
IBinaryKeyData,
|
||||||
|
@ -312,8 +309,9 @@ export class Signl4 implements INodeType {
|
||||||
throw new NodeOperationError(this.getNode(), `Invalid extension, just ${supportedFileExtension.join(',')} are supported}`);
|
throw new NodeOperationError(this.getNode(), `Invalid extension, just ${supportedFileExtension.join(',')} are supported}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, propertyName);
|
||||||
data.attachment = {
|
data.attachment = {
|
||||||
value: Buffer.from(binaryProperty.data, BINARY_ENCODING),
|
value: binaryDataBuffer,
|
||||||
options: {
|
options: {
|
||||||
filename: binaryProperty.fileName,
|
filename: binaryProperty.fileName,
|
||||||
contentType: binaryProperty.mimeType,
|
contentType: binaryProperty.mimeType,
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
|
||||||
} from 'n8n-core';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ICredentialsDecrypted,
|
ICredentialsDecrypted,
|
||||||
|
@ -977,9 +974,10 @@ export class Slack implements INodeType {
|
||||||
|| items[i].binary[binaryPropertyName] === undefined) {
|
|| items[i].binary[binaryPropertyName] === undefined) {
|
||||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
|
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 = {
|
body.file = {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
value: Buffer.from(items[i].binary[binaryPropertyName].data, BINARY_ENCODING),
|
value: binaryDataBuffer,
|
||||||
options: {
|
options: {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
filename: items[i].binary[binaryPropertyName].fileName,
|
filename: items[i].binary[binaryPropertyName].fileName,
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IExecuteFunctions } from 'n8n-core';
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
|
||||||
} from 'n8n-core';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
|
@ -346,7 +343,7 @@ export class SpreadsheetFile implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the binary spreadsheet data
|
// 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;
|
let workbook;
|
||||||
if (options.readAsString === true) {
|
if (options.readAsString === true) {
|
||||||
workbook = xlsxRead(binaryData.toString(), { type: 'string', raw: options.rawData as boolean });
|
workbook = xlsxRead(binaryData.toString(), { type: 'string', raw: options.rawData as boolean });
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import {
|
import {
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
IHookFunctions,
|
IHookFunctions,
|
||||||
ILoadOptionsFunctions,
|
ILoadOptionsFunctions,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {
|
import {
|
||||||
|
BINARY_ENCODING,
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
WAIT_TIME_UNLIMITED,
|
WAIT_TIME_UNLIMITED,
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import {
|
import {
|
||||||
BINARY_ENCODING,
|
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
import {
|
import {
|
||||||
|
@ -217,10 +216,12 @@ export class Zulip implements INodeType {
|
||||||
if (items[i].binary[binaryProperty] === undefined) {
|
if (items[i].binary[binaryProperty] === undefined) {
|
||||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryProperty}" does not exists on item!`);
|
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 = {
|
const formData = {
|
||||||
file: {
|
file: {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
value: Buffer.from(items[i].binary[binaryProperty].data, BINARY_ENCODING),
|
value: binaryDataBuffer,
|
||||||
options: {
|
options: {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
filename: items[i].binary[binaryProperty].fileName,
|
filename: items[i].binary[binaryProperty].fileName,
|
||||||
|
|
Loading…
Reference in a new issue