pull:初次提交

This commit is contained in:
Yep_Q
2025-09-08 04:48:28 +08:00
parent 5c0619656d
commit f64f498365
11751 changed files with 1953723 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
{
"node": "n8n-nodes-base.readBinaryFiles",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Core Nodes"],
"resources": {
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.readwritefile/"
}
]
},
"alias": ["Text", "Open", "Import"],
"subcategories": {
"Core Nodes": ["Files"]
}
}

View File

@@ -0,0 +1,69 @@
import glob from 'fast-glob';
import {
NodeConnectionTypes,
type IExecuteFunctions,
type INodeExecutionData,
type INodeType,
type INodeTypeDescription,
} from 'n8n-workflow';
import { generatePairedItemData } from '../../utils/utilities';
export class ReadBinaryFiles implements INodeType {
description: INodeTypeDescription = {
hidden: true,
displayName: 'Read Binary Files',
name: 'readBinaryFiles',
icon: 'fa:file-import',
group: ['input'],
version: 1,
description: 'Reads binary files from disk',
defaults: {
name: 'Read Binary Files',
color: '#44AA44',
},
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
properties: [
{
displayName: 'File Selector',
name: 'fileSelector',
type: 'string',
default: '',
required: true,
placeholder: '*.jpg',
description: 'Pattern for files to read',
},
{
displayName: 'Property Name',
name: 'dataPropertyName',
type: 'string',
default: 'data',
required: true,
description: 'Name of the binary property to which to write the data of the read files',
},
],
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const fileSelector = this.getNodeParameter('fileSelector', 0) as string;
const dataPropertyName = this.getNodeParameter('dataPropertyName', 0);
const pairedItem = generatePairedItemData(this.getInputData().length);
const files = await glob(fileSelector);
const items: INodeExecutionData[] = [];
for (const filePath of files) {
const stream = await this.helpers.createReadStream(filePath);
items.push({
binary: {
[dataPropertyName]: await this.helpers.prepareBinaryData(stream, filePath),
},
json: {},
pairedItem,
});
}
return [items];
}
}

View File

@@ -0,0 +1,59 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import type { WorkflowTestData } from 'n8n-workflow';
import path from 'path';
describe('Test Read Binary Files Node', () => {
const testHarness = new NodeTestHarness();
const workflowData = testHarness.readWorkflowJSON('ReadBinaryFiles.workflow.json');
const node = workflowData.nodes.find((n) => n.name === 'Read Binary Files')!;
const dir = path.join(__dirname, 'data').split('\\').join('/');
node.parameters.fileSelector = `${dir}/*.json`;
const tests: WorkflowTestData[] = [
{
description: 'nodes/ReadBinaryFiles/test/ReadBinaryFiles.workflow.json',
input: {
workflowData,
},
output: {
assertBinaryData: true,
nodeData: {
'Read Binary Files': [
[
{
binary: {
data: {
mimeType: 'application/json',
fileType: 'json',
fileExtension: 'json',
data: 'ewoJInRpdGxlIjogIkxvcmVtIElwc3VtIgp9Cg==',
fileName: 'sample.json',
fileSize: '28 B',
},
},
json: {},
},
{
binary: {
data: {
mimeType: 'application/json',
fileType: 'json',
fileExtension: 'json',
data: 'ewoJInRpdGxlIjogIklwc3VtIExvcmVtIgp9Cg==',
fileName: 'sample2.json',
fileSize: '28 B',
},
},
json: {},
},
],
],
},
},
},
];
for (const testData of tests) {
testHarness.setupTest(testData);
}
});

View File

@@ -0,0 +1,45 @@
{
"name": "Read Binary Files test",
"nodes": [
{
"parameters": {},
"id": "90c8a569-5351-44a4-9073-b8d114108676",
"name": "When clicking \"Execute Workflow\"",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [680, 640]
},
{
"parameters": {
"fileSelector": "C:/Test/data/*.json"
},
"id": "b4974ce2-9bc8-4242-b6f9-86b43608b521",
"name": "Read Binary Files",
"type": "n8n-nodes-base.readBinaryFiles",
"typeVersion": 1,
"position": [880, 640]
}
],
"pinData": {},
"connections": {
"When clicking \"Execute Workflow\"": {
"main": [
[
{
"node": "Read Binary Files",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {},
"versionId": "973f1d06-f5e6-4e05-8136-02f6518ad37b",
"id": "190",
"meta": {
"instanceId": "104a4d08d8897b8bdeb38aaca515021075e0bd8544c983c2bb8c86e6a8e6081c"
},
"tags": []
}

View File

@@ -0,0 +1,3 @@
{
"title": "Lorem Ipsum"
}

View File

@@ -0,0 +1,3 @@
{
"title": "Ipsum Lorem"
}