UNPKG

azure-kusto-ingest

Version:
36 lines 1.83 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import { BlobDescriptor, generateBlobName, StreamDescriptor } from "./descriptors.js"; import { FileDescriptor } from "./fileDescriptor.browser.js"; import { KustoIngestClientBase } from "./ingestClientBase.js"; export class KustoIngestClient extends KustoIngestClientBase { constructor(kcsb, defaultProps, autoCorrectEndpoint) { super(kcsb, defaultProps, autoCorrectEndpoint, true); } /** * Use string for Node.js and Blob in browser */ async ingestFromFile(file, ingestionProperties) { this.ensureOpen(); const descriptor = file instanceof FileDescriptor ? file : new FileDescriptor(file); const blob = descriptor.file; const props = this._getMergedProps(ingestionProperties); const fileToUpload = await descriptor.prepare(ingestionProperties); const blobName = generateBlobName(descriptor, props); const blobUri = await this.uploadToBlobWithRetry(fileToUpload, blobName); return this.ingestFromBlob(new BlobDescriptor(blobUri, blob.size, descriptor.sourceId), props); } /** * Use Readable for Node.js and ArrayBuffer in browser */ async ingestFromStream(stream, ingestionProperties) { this.ensureOpen(); const props = this._getMergedProps(ingestionProperties); const descriptor = stream instanceof StreamDescriptor ? stream : new StreamDescriptor(stream); const blobName = generateBlobName(descriptor, props); const blobUri = await this.uploadToBlobWithRetry(descriptor.stream, blobName); return this.ingestFromBlob(new BlobDescriptor(blobUri, descriptor.size, descriptor.sourceId), props); } } export default KustoIngestClient; //# sourceMappingURL=ingestClient.browser.js.map