UNPKG

@itwin/object-storage-core

Version:
40 lines 1.63 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.StrategyFrontendStorage = void 0; const common_1 = require("../common"); const FrontendStorage_1 = require("./FrontendStorage"); class StrategyFrontendStorage extends FrontendStorage_1.FrontendStorage { _clients = new Map(); constructor(clients) { super(); for (const client of clients) { this._clients.set(client.instanceName, client.instance); } } getClient(input) { const storageType = (0, common_1.inputToStorageType)(input); const client = this._clients.get(storageType); if (client === undefined) { throw new Error(`Client for storage type ${storageType} not found`); } return client; } download(input) { if (input.transferType === "buffer") { return this.getClient(input).download(input); } return this.getClient(input).download(input); } upload(input) { return this.getClient(input).upload(input); } uploadInMultipleParts(input) { return this.getClient(input).uploadInMultipleParts(input); } } exports.StrategyFrontendStorage = StrategyFrontendStorage; //# sourceMappingURL=StrategyFrontendStorage.js.map