in packages/azure-kusto-ingest/src/managedStreamingIngestClient.ts [108:156]
isNode ? (descriptor.size ?? 0) : (descriptor.stream as ArrayBuffer).byteLength,
descriptor,
props,
clientRequestId,
result,
);
result = isNode ? readableToStream(result) : descriptor.stream;
}
return streamingResult ?? this.queuedIngestClient.ingestFromStream(new StreamDescriptor(result).merge(descriptor), props);
}
/**
* Use string for Node.js and Blob in browser
*/
async ingestFromFile(
file: FileDescriptor | string | Blob,
ingestionProperties?: IngestionPropertiesInput,
): Promise<KustoResponseDataSet | IngestionResult> {
this.ensureOpen();
const stream = file instanceof FileDescriptor ? await tryFileToBuffer(file) : await tryFileToBuffer(new FileDescriptor(file));
return await this.ingestFromStream(stream, ingestionProperties);
}
async ingestFromBlob(
blob: string | BlobDescriptor,
ingestionProperties?: IngestionPropertiesInput,
clientRequestId?: string,
): Promise<KustoResponseDataSet | IngestionResult> {
const props = this._getMergedProps(ingestionProperties);
const descriptor = blob instanceof BlobDescriptor ? blob : new BlobDescriptor(blob);
// No need to check blob size if it was given to us that it's not empty
await descriptor.fillSize();
const streamingResult = await this.streamWithRetries(descriptor.size ?? 0, descriptor, props, clientRequestId);
return streamingResult ?? this.queuedIngestClient.ingestFromBlob(descriptor, props);
}
async streamWithRetries(
length: number,
descriptor: AbstractDescriptor,
props?: IngestionPropertiesInput,
clientRequestId?: string,
stream?: Readable | ArrayBuffer,
): Promise<any> {
const isBlob = descriptor instanceof BlobDescriptor;
if (length <= maxStreamSize) {