// Copyright Abridged, Inc. 2021,2024. All Rights Reserved. // Node module: @collabland/aws // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT import { DeleteObjectCommandInput, GetObjectCommandInput, PutObjectCommandInput, S3, S3ClientConfig, } from '@aws-sdk/client-s3'; import {loggers} from '@collabland/common'; import {getDefaultConfig} from '../common/types.js'; import {XRayServiceClient} from '../xray/xray.client.js'; const {trace} = loggers('collabland:aws:s3'); export class S3ServiceClient { readonly s3: S3; xray?: XRayServiceClient; constructor(options?: S3ClientConfig) { this.s3 = new S3({ ...getDefaultConfig(), ...options, }); } async putObject(input: PutObjectCommandInput) { trace('Putting object: %O', input); const output = await this.s3.putObject(input); trace('Object created: %O', output); return output; } async getObject(input: GetObjectCommandInput) { trace('Getting object: %O', input); const output = await this.s3.getObject(input); trace('Object metadata received: %O', output.Metadata); return output; } async deleteObject(input: DeleteObjectCommandInput) { trace('Deleting object: %O', input); const output = await this.s3.deleteObject(input); return output; } }