UNPKG

@itwin/object-storage-minio

Version:
36 lines 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createMinioS3ClientFrontend = createMinioS3ClientFrontend; exports.handleMinioUrlUploadFrontend = handleMinioUrlUploadFrontend; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ const client_s3_1 = require("@aws-sdk/client-s3"); const internal_1 = require("@itwin/object-storage-core/lib/common/internal"); const internal_2 = require("@itwin/object-storage-core/lib/frontend/internal"); function createMinioS3ClientFrontend(config) { const { baseUrl, region, accessKey, secretKey, sessionToken } = config; const endpointUrl = new URL(baseUrl); const endpoint = { url: endpointUrl, }; return new client_s3_1.S3Client({ endpoint, region, credentials: { accessKeyId: accessKey, secretAccessKey: secretKey, sessionToken, }, forcePathStyle: true, }); } async function handleMinioUrlUploadFrontend(input) { const { data, metadata, url } = input; const headers = metadata ? (0, internal_1.metadataToHeaders)(metadata, "x-amz-meta-") : undefined; return (0, internal_2.uploadToUrlFrontend)(url, data, "PUT", headers); } //# sourceMappingURL=Helpers.js.map