From 38e63d1546095512cf020912b0ca6e3073c3eec1 Mon Sep 17 00:00:00 2001 From: Vlad Hashimoto Date: Wed, 1 Apr 2020 01:35:48 +0300 Subject: [PATCH] feat(s3): add options to allow use custom instance (#1601) Co-authored-by: Mark Lee --- packages/publisher/s3/src/Config.ts | 18 ++++++++++++++++++ packages/publisher/s3/src/PublisherS3.ts | 3 +++ 2 files changed, 21 insertions(+) diff --git a/packages/publisher/s3/src/Config.ts b/packages/publisher/s3/src/Config.ts index d5310af83a..7204757cbb 100644 --- a/packages/publisher/s3/src/Config.ts +++ b/packages/publisher/s3/src/Config.ts @@ -31,6 +31,24 @@ export interface PublisherS3Config { * Default: false */ public?: boolean; + /** + * The endpoint URI to send requests to. + * + * E.g. `https://s3.example.com` + */ + endpoint?: string; + /** + * The region to send service requests to. + * + * E.g. `eu-west-1` + */ + region?: string; + /** + * Whether to force path style URLs for S3 objects. + * + * Default: false + */ + s3ForcePathStyle?: boolean; /** * Custom function to provide the key to upload a given file to */ diff --git a/packages/publisher/s3/src/PublisherS3.ts b/packages/publisher/s3/src/PublisherS3.ts index 676a24b842..c604c3dc96 100644 --- a/packages/publisher/s3/src/PublisherS3.ts +++ b/packages/publisher/s3/src/PublisherS3.ts @@ -38,6 +38,9 @@ export default class PublisherS3 extends PublisherBase { const s3Client = new S3({ accessKeyId: config.accessKeyId || process.env.AWS_ACCESS_KEY_ID, secretAccessKey: config.secretAccessKey || process.env.AWS_SECRET_ACCESS_KEY, + region: config.region || undefined, + endpoint: config.endpoint || undefined, + s3ForcePathStyle: !!config.s3ForcePathStyle, }); if (!s3Client.config.credentials || !config.bucket) {