@itwin/object-storage-google
Version:
Object storage implementation using Google Cloud Storage
41 lines • 1.84 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* 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.StorageWrapperFactory = void 0;
const storage_1 = require("@google-cloud/storage");
const StorageWrapper_1 = require("./StorageWrapper");
class StorageWrapperFactory {
_retryOptions;
constructor(_retryOptions = {}) {
this._retryOptions = _retryOptions;
}
createDefaultApplication(config) {
return new StorageWrapper_1.StorageWrapper(new storage_1.Storage({
projectId: config.projectId,
retryOptions: {
autoRetry: true,
maxRetries: this._retryOptions.maxRetries,
maxRetryDelay: this._retryOptions.maxRetryDelayMs !== undefined
? this._retryOptions.maxRetryDelayMs / 1000
: undefined,
},
}), config);
}
createFromToken(transferConfig) {
return new StorageWrapper_1.StorageWrapper(new storage_1.Storage({
token: transferConfig.authentication,
retryOptions: {
autoRetry: true,
maxRetries: this._retryOptions.maxRetries,
maxRetryDelay: this._retryOptions.maxRetryDelayMs !== undefined
? this._retryOptions.maxRetryDelayMs / 1000
: undefined,
},
}), { bucketName: transferConfig.bucketName });
}
}
exports.StorageWrapperFactory = StorageWrapperFactory;
//# sourceMappingURL=StorageWrapperFactory.js.map