UNPKG

@itwin/object-storage-azure

Version:

Object storage implementation using Azure Blob Storage

52 lines 2.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AzureClientStorage = void 0; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ const fs_1 = require("fs"); const path_1 = require("path"); const internal_1 = require("@itwin/object-storage-core/lib/common/internal"); const internal_2 = require("@itwin/object-storage-core/lib/server/internal"); const object_storage_core_1 = require("@itwin/object-storage-core"); class AzureClientStorage extends object_storage_core_1.ClientStorage { _clientWrapperFactory; constructor(_clientWrapperFactory) { super(); this._clientWrapperFactory = _clientWrapperFactory; } async download(input) { if ("reference" in input) (0, internal_1.assertRelativeDirectory)(input.reference.relativeDirectory); if ((0, internal_2.isLocalTransferInput)(input)) await fs_1.promises.mkdir((0, path_1.dirname)(input.localPath), { recursive: true }); const options = { abortSignal: input.abortSignal, }; const downloadStream = await this._clientWrapperFactory .create(input) .download(options); return (0, internal_2.streamToTransferType)(downloadStream, input.transferType, input.localPath); } async upload(input) { if ("reference" in input) (0, internal_1.assertRelativeDirectory)(input.reference.relativeDirectory); if (typeof input.data === "string") await (0, internal_2.assertFileNotEmpty)(input.data); return this._clientWrapperFactory .create(input) .upload(input.data, input.metadata); } async uploadInMultipleParts(input) { if ("reference" in input) (0, internal_1.assertRelativeDirectory)(input.reference.relativeDirectory); if (typeof input.data === "string") await (0, internal_2.assertFileNotEmpty)(input.data); return this._clientWrapperFactory .create(input) .uploadInMultipleParts(input.data, input.options); } } exports.AzureClientStorage = AzureClientStorage; //# sourceMappingURL=AzureClientStorage.js.map