refactor(Google Drive Node): Use node streams for uploading and downloading files (#5017)

* use streams to upload files to google drive

* use streams to download files from google drive

* use resumable uploads api for google drive

* avoid dangling promises, and reduce memory usage in error logging
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-01-04 12:29:56 +01:00
committed by GitHub
parent 8b19fdd5f0
commit 54126b2c87
6 changed files with 229 additions and 163 deletions

View File

@@ -40,10 +40,16 @@ export interface IBinaryData {
fileName?: string;
directory?: string;
fileExtension?: string;
fileSize?: string;
fileSize?: string; // TODO: change this to number and store the actual value
id?: string;
}
export interface BinaryMetadata {
fileName?: string;
mimeType?: string;
fileSize: number;
}
// All properties in this interface except for
// "includeCredentialsOnRefreshOnBody" will get
// removed once we add the OAuth2 hooks to the
@@ -641,6 +647,9 @@ export interface BinaryHelperFunctions {
): Promise<IBinaryData>;
setBinaryDataBuffer(data: IBinaryData, binaryData: Buffer): Promise<IBinaryData>;
copyBinaryFile(filePath: string, fileName: string, mimeType?: string): Promise<IBinaryData>;
getBinaryStream(binaryDataId: string, chunkSize?: number): Readable;
getBinaryMetadata(binaryDataId: string): Promise<BinaryMetadata>;
}
export interface RequestHelperFunctions {
@@ -721,7 +730,6 @@ export type IExecuteFunctions = ExecuteFunctions.GetNodeParameterFn &
inputData: INodeExecutionData[],
options: { itemData: IPairedItemData | IPairedItemData[] },
): NodeExecutionWithMetadata[];
getBinaryDataBuffer(itemIndex: number, propertyName: string): Promise<Buffer>;
};
};