refactor(Read Binary File Node): Use node streams for to reduce memory usage (#5069)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-01-02 17:07:10 +01:00
committed by GitHub
parent a455cce7e6
commit 8bee04cd2a
9 changed files with 55 additions and 25 deletions

View File

@@ -6,7 +6,7 @@ import {
NodeOperationError,
} from 'n8n-workflow';
import { readFile as fsReadFile } from 'fs/promises';
import { createReadStream } from 'fs';
export class ReadBinaryFile implements INodeType {
description: INodeTypeDescription = {
@@ -58,7 +58,7 @@ export class ReadBinaryFile implements INodeType {
let data;
try {
data = await fsReadFile(filePath);
data = createReadStream(filePath);
} catch (error) {
if (error.code === 'ENOENT') {
throw new NodeOperationError(