From 10bff4c5b7645038ae3a349041e4200e6a019165 Mon Sep 17 00:00:00 2001 From: Pez Cuckow Date: Tue, 5 Dec 2023 19:21:33 +0100 Subject: [PATCH 1/2] Possible fix for config issue with S3 --- src/AdapterAmazonS3.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/AdapterAmazonS3.ts b/src/AdapterAmazonS3.ts index 005a3fb..38244f1 100644 --- a/src/AdapterAmazonS3.ts +++ b/src/AdapterAmazonS3.ts @@ -55,18 +55,20 @@ export class AdapterAmazonS3 extends AbstractAdapter { } else { this.region = (this.config as ConfigAmazonS3).region; } - if (typeof this.config.endpoint === "undefined") { - this.storage = new S3Client({ region: this.region }); - } else { - this.storage = new S3Client({ + + const config = { region: this.region, - endpoint: this.config.endpoint, credentials: { accessKeyId: this.config.accessKeyId, secretAccessKey: this.config.secretAccessKey, }, - }); + } + + if (typeof this.config.endpoint !== "undefined") { + config.endpoint = this.config.endpoint; } + + this.storage = new S3Client(config); } async init(): Promise { From 62042a79ad314e99f487577525199a27d2e40cf4 Mon Sep 17 00:00:00 2001 From: Pez Cuckow Date: Tue, 5 Dec 2023 19:33:01 +0100 Subject: [PATCH 2/2] Set explicit type on object --- src/AdapterAmazonS3.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/AdapterAmazonS3.ts b/src/AdapterAmazonS3.ts index 38244f1..c950f7c 100644 --- a/src/AdapterAmazonS3.ts +++ b/src/AdapterAmazonS3.ts @@ -17,6 +17,7 @@ import { ListObjectsCommand, PutObjectCommand, S3Client, + S3ClientConfig, } from "@aws-sdk/client-s3"; import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; import { ConfigAmazonS3, AdapterConfig, StorageType, S3Compatible } from "./types"; @@ -55,20 +56,20 @@ export class AdapterAmazonS3 extends AbstractAdapter { } else { this.region = (this.config as ConfigAmazonS3).region; } - - const config = { - region: this.region, - credentials: { - accessKeyId: this.config.accessKeyId, - secretAccessKey: this.config.secretAccessKey, - }, - } + + const s3Config: S3ClientConfig = { + region: this.region, + credentials: { + accessKeyId: this.config.accessKeyId, + secretAccessKey: this.config.secretAccessKey, + }, + }; if (typeof this.config.endpoint !== "undefined") { - config.endpoint = this.config.endpoint; + s3Config.endpoint = this.config.endpoint; } - - this.storage = new S3Client(config); + + this.storage = new S3Client(s3Config); } async init(): Promise {