Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible fix for config issue with S3 #49

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/AdapterAmazonS3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -55,18 +56,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({
region: this.region,
endpoint: this.config.endpoint,
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") {
s3Config.endpoint = this.config.endpoint;
}

this.storage = new S3Client(s3Config);
}

async init(): Promise<boolean> {
Expand Down