UNPKG

@itwin/object-storage-azure

Version:

Object storage implementation using Azure Blob Storage

48 lines 2.17 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); exports.AzureFrontendStorage = void 0; const internal_1 = require("@itwin/object-storage-core/lib/common/internal"); const frontend_1 = require("@itwin/object-storage-core/lib/frontend"); class AzureFrontendStorage extends frontend_1.FrontendStorage { _clientWrapperFactory; constructor(_clientWrapperFactory) { super(); this._clientWrapperFactory = _clientWrapperFactory; } async download(input) { if ("reference" in input) (0, internal_1.assertRelativeDirectory)(input.reference.relativeDirectory); const downloadBlob = await this._clientWrapperFactory .create(input) .download(); switch (input.transferType) { case "buffer": return downloadBlob.arrayBuffer(); case "stream": return downloadBlob.stream(); default: // eslint-disable-next-line @typescript-eslint/restrict-template-expressions throw new Error(`Transfer type ${input.transferType} is unsupported`); } } async upload(input) { if ("reference" in input) (0, internal_1.assertRelativeDirectory)(input.reference.relativeDirectory); return this._clientWrapperFactory .create(input) .upload(input.data, input.metadata); } async uploadInMultipleParts(input) { if ("reference" in input) (0, internal_1.assertRelativeDirectory)(input.reference.relativeDirectory); return this._clientWrapperFactory .create(input) .uploadInMultipleParts(input.data, input.options); } } exports.AzureFrontendStorage = AzureFrontendStorage; //# sourceMappingURL=AzureFrontendStorage.js.map