mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
Remove executeSingle from ReadBinaryFile node
This commit is contained in:
parent
46d1a5fe58
commit
8d119852f6
|
@ -134,7 +134,7 @@ export class EmailSend implements INodeType {
|
|||
for (let itemIndex = 0; itemIndex < length; itemIndex++) {
|
||||
|
||||
item = items[itemIndex];
|
||||
console.log(item,itemIndex)
|
||||
|
||||
const fromEmail = this.getNodeParameter('fromEmail', itemIndex) as string;
|
||||
const toEmail = this.getNodeParameter('toEmail', itemIndex) as string;
|
||||
const ccEmail = this.getNodeParameter('ccEmail', itemIndex) as string;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IExecuteSingleFunctions } from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
|
@ -49,38 +49,46 @@ export class ReadBinaryFile implements INodeType {
|
|||
};
|
||||
|
||||
|
||||
async executeSingle(this: IExecuteSingleFunctions): Promise<INodeExecutionData> {
|
||||
const item = this.getInputData();
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
|
||||
const dataPropertyName = this.getNodeParameter('dataPropertyName') as string;
|
||||
const filePath = this.getNodeParameter('filePath') as string;
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
let item: INodeExecutionData;
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = await fsReadFileAsync(filePath) as Buffer;
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
throw new Error(`The file "${filePath}" could not be found.`);
|
||||
for (let itemIndex = 0; itemIndex < length; itemIndex++) {
|
||||
item = items[itemIndex];
|
||||
const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string;
|
||||
const filePath = this.getNodeParameter('filePath', itemIndex) as string;
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = await fsReadFileAsync(filePath) as Buffer;
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
throw new Error(`The file "${filePath}" could not be found.`);
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
const newItem: INodeExecutionData = {
|
||||
json: item.json,
|
||||
binary: {},
|
||||
};
|
||||
|
||||
const newItem: INodeExecutionData = {
|
||||
json: item.json,
|
||||
binary: {},
|
||||
};
|
||||
if (item.binary !== undefined) {
|
||||
// Create a shallow copy of the binary data so that the old
|
||||
// data references which do not get changed still stay behind
|
||||
// but the incoming data does not get changed.
|
||||
Object.assign(newItem.binary, item.binary);
|
||||
}
|
||||
|
||||
if (item.binary !== undefined) {
|
||||
// Create a shallow copy of the binary data so that the old
|
||||
// data references which do not get changed still stay behind
|
||||
// but the incoming data does not get changed.
|
||||
Object.assign(newItem.binary, item.binary);
|
||||
}
|
||||
|
||||
newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData(data, filePath);
|
||||
|
||||
return newItem;
|
||||
newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData(data, filePath);
|
||||
returnData.push(newItem);
|
||||
}
|
||||
|
||||
return this.prepareOutputData(returnData);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue