mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(core): Improvements/overhaul for nodes working with binary data (#7651)
Github issue / Community forum post (link here to close automatically): --------- Co-authored-by: Giulio Andreini <andreini@netseven.it> Co-authored-by: Marcus <marcus@n8n.io>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import * as read from './actions/read.operation';
|
||||
import * as write from './actions/write.operation';
|
||||
|
||||
export class ReadWriteFile implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Read/Write Files from Disk',
|
||||
name: 'readWriteFile',
|
||||
icon: 'file:readWriteFile.svg',
|
||||
group: ['input'],
|
||||
version: 1,
|
||||
description: 'Read or write files from the computer that runs n8n',
|
||||
defaults: {
|
||||
name: 'Read/Write Files from Disk',
|
||||
},
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
properties: [
|
||||
{
|
||||
displayName:
|
||||
'Use this node to read and write files on the same computer running n8n. To handle files between different computers please use other nodes (e.g. FTP, HTTP Request, AWS).',
|
||||
name: 'info',
|
||||
type: 'notice',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Read File(s) From Disk',
|
||||
value: 'read',
|
||||
description: 'Retrieve one or more files from the computer that runs n8n',
|
||||
action: 'Read File(s) From Disk',
|
||||
},
|
||||
{
|
||||
name: 'Write File to Disk',
|
||||
value: 'write',
|
||||
description: 'Create a binary file on the computer that runs n8n',
|
||||
action: 'Write File to Disk',
|
||||
},
|
||||
],
|
||||
default: 'read',
|
||||
},
|
||||
...read.description,
|
||||
...write.description,
|
||||
],
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions) {
|
||||
const operation = this.getNodeParameter('operation', 0, 'read');
|
||||
const items = this.getInputData();
|
||||
let returnData: INodeExecutionData[] = [];
|
||||
|
||||
if (operation === 'read') {
|
||||
returnData = await read.execute.call(this, items);
|
||||
}
|
||||
|
||||
if (operation === 'write') {
|
||||
returnData = await write.execute.call(this, items);
|
||||
}
|
||||
|
||||
return [returnData];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user