mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 03:42:16 +00:00
fix(core): Add a helper function to convert binary streams to buffers (no-changelog) (#5641)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import concatStream from 'concat-stream';
|
||||
import { readFile, stat } from 'fs/promises';
|
||||
import type { BinaryMetadata, IBinaryData, INodeExecutionData } from 'n8n-workflow';
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
@@ -6,6 +5,7 @@ import type { Readable } from 'stream';
|
||||
import { BINARY_ENCODING } from '../Constants';
|
||||
import type { IBinaryDataConfig, IBinaryDataManager } from '../Interfaces';
|
||||
import { BinaryDataFileSystem } from './FileSystem';
|
||||
import { binaryToBuffer } from './utils';
|
||||
|
||||
export class BinaryDataManager {
|
||||
static instance: BinaryDataManager | undefined;
|
||||
@@ -104,11 +104,7 @@ export class BinaryDataManager {
|
||||
fileSize,
|
||||
});
|
||||
} else {
|
||||
// Else fallback to storing this data in memory.
|
||||
const buffer = await new Promise<Buffer>((resolve) => {
|
||||
if (Buffer.isBuffer(input)) resolve(input);
|
||||
else input.pipe(concatStream(resolve));
|
||||
});
|
||||
const buffer = await binaryToBuffer(input);
|
||||
binaryData.data = buffer.toString(BINARY_ENCODING);
|
||||
binaryData.fileSize = prettyBytes(buffer.length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user