refactor(core)!: Make getBinaryStream async (#7247)
Story: [PAY-846](https://linear.app/n8n/issue/PAY-846) | Related: https://github.com/n8n-io/n8n/pull/7225 For the S3 backend for external storage of binary data and execution data, the `getAsStream` method in the binary data manager interface used by FS and S3 will need to become async. This is a breaking change for nodes-base.
This commit is contained in:
@@ -89,7 +89,7 @@ export class BinaryDataService {
|
||||
});
|
||||
}
|
||||
|
||||
getAsStream(binaryDataId: string, chunkSize?: number) {
|
||||
async getAsStream(binaryDataId: string, chunkSize?: number) {
|
||||
const [mode, fileId] = binaryDataId.split(':');
|
||||
|
||||
return this.getManager(mode).getAsStream(fileId, chunkSize);
|
||||
|
||||
@@ -36,7 +36,7 @@ export class FileSystemManager implements BinaryData.Manager {
|
||||
}
|
||||
}
|
||||
|
||||
getAsStream(fileId: string, chunkSize?: number) {
|
||||
async getAsStream(fileId: string, chunkSize?: number) {
|
||||
const filePath = this.getPath(fileId);
|
||||
|
||||
return createReadStream(filePath, { highWaterMark: chunkSize });
|
||||
|
||||
@@ -29,7 +29,7 @@ export namespace BinaryData {
|
||||
|
||||
getPath(fileId: string): string;
|
||||
getAsBuffer(fileId: string): Promise<Buffer>;
|
||||
getAsStream(fileId: string, chunkSize?: number): Readable;
|
||||
getAsStream(fileId: string, chunkSize?: number): Promise<Readable>;
|
||||
getMetadata(fileId: string): Promise<Metadata>;
|
||||
|
||||
// @TODO: Refactor to also use `workflowId` to support full path-like identifier:
|
||||
|
||||
@@ -954,7 +954,7 @@ export async function getBinaryMetadata(binaryDataId: string): Promise<BinaryDat
|
||||
/**
|
||||
* Returns binary file stream for piping
|
||||
*/
|
||||
export function getBinaryStream(binaryDataId: string, chunkSize?: number): Readable {
|
||||
export async function getBinaryStream(binaryDataId: string, chunkSize?: number): Promise<Readable> {
|
||||
return Container.get(BinaryDataService).getAsStream(binaryDataId, chunkSize);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user