feat(Google Cloud Storage Node): Use streaming for file uploads (#6462)

fix(Google Cloud Storage Node): Use streaming for file uploads
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-07-19 12:54:31 +02:00
committed by GitHub
parent c7b74c3c1f
commit cd0e41a6b4
6 changed files with 30 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
import FormData from 'form-data';
import type { BinaryFileType, JsonObject } from './Interfaces';
const readStreamClasses = new Set(['ReadStream', 'Readable', 'ReadableStream']);
@@ -5,6 +6,7 @@ const readStreamClasses = new Set(['ReadStream', 'Readable', 'ReadableStream']);
export const isObjectEmpty = (obj: object | null | undefined): boolean => {
if (obj === undefined || obj === null) return true;
if (typeof obj === 'object') {
if (obj instanceof FormData) return obj.getLengthSync() === 0;
if (Array.isArray(obj)) return obj.length === 0;
if (obj instanceof Set || obj instanceof Map) return obj.size === 0;
if (ArrayBuffer.isView(obj) || obj instanceof ArrayBuffer) return obj.byteLength === 0;