From bbafeda4c6e58ff1422425b1cea8ee7b17d86df6 Mon Sep 17 00:00:00 2001 From: prakashsvmx Date: Mon, 13 May 2024 10:55:54 +0530 Subject: [PATCH] fix use configured region from constructor for makebucket --- README.md | 2 +- README_zh_CN.md | 2 +- examples/{make-bucket.js => make-bucket.mjs} | 5 +++++ src/internal/client.ts | 7 +++---- 4 files changed, 10 insertions(+), 6 deletions(-) rename examples/{make-bucket.js => make-bucket.mjs} (91%) diff --git a/README.md b/README.md index c48a7195..9cde67a9 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ The complete API Reference is available here: - [list-objects-v2.js](https://github.com/minio/minio-js/blob/master/examples/list-objects-v2.js) - [list-objects-v2-with-metadata.js](https://github.com/minio/minio-js/blob/master/examples/list-objects-v2-with-metadata.js) (Extension) - [bucket-exists.mjs](https://github.com/minio/minio-js/blob/master/examples/bucket-exists.mjs) -- [make-bucket.js](https://github.com/minio/minio-js/blob/master/examples/make-bucket.js) +- [make-bucket.mjs](https://github.com/minio/minio-js/blob/master/examples/make-bucket.js) - [remove-bucket.mjs](https://github.com/minio/minio-js/blob/master/examples/remove-bucket.mjs) - [list-incomplete-uploads.js](https://github.com/minio/minio-js/blob/master/examples/list-incomplete-uploads.js) - [get-bucket-versioning.mjs](https://github.com/minio/minio-js/blob/master/examples/get-bucket-versioning.js) diff --git a/README_zh_CN.md b/README_zh_CN.md index a792f7f9..f8f2b8f8 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -155,7 +155,7 @@ mc ls play/europetrip/ * [list-objects.js](https://github.com/minio/minio-js/blob/master/examples/list-objects.js) * [list-objects-v2.js](https://github.com/minio/minio-js/blob/master/examples/list-objects-v2.js) * [bucket-exists.mjs](https://github.com/minio/minio-js/blob/master/examples/bucket-exists.mjs) -* [make-bucket.js](https://github.com/minio/minio-js/blob/master/examples/make-bucket.js) +* [make-bucket.mjs](https://github.com/minio/minio-js/blob/master/examples/make-bucket.js) * [remove-bucket.mjs](https://github.com/minio/minio-js/blob/master/examples/remove-bucket.mjs) * [list-incomplete-uploads.js](https://github.com/minio/minio-js/blob/master/examples/list-incomplete-uploads.js) diff --git a/examples/make-bucket.js b/examples/make-bucket.mjs similarity index 91% rename from examples/make-bucket.js rename to examples/make-bucket.mjs index bb0389d8..eca9fe55 100644 --- a/examples/make-bucket.js +++ b/examples/make-bucket.mjs @@ -24,6 +24,11 @@ const s3Client = new Minio.Client({ accessKey: 'YOUR-ACCESSKEYID', secretKey: 'YOUR-SECRETACCESSKEY', }) + +// Create a bucket name my-bucketname-nr. +await s3Client.makeBucket('my-bucketname-nr') +console.log('Success') + // Create a bucket name my-bucketname. await s3Client.makeBucket('my-bucketname', 'us-west-1') diff --git a/src/internal/client.ts b/src/internal/client.ts index 3b6e26fe..7b028903 100644 --- a/src/internal/client.ts +++ b/src/internal/client.ts @@ -892,10 +892,9 @@ export class TypedClient { headers['x-amz-bucket-object-lock-enabled'] = true } - if (!region) { - region = DEFAULT_REGION - } - const finalRegion = region // type narrow + // For custom region clients default to custom region specified in client constructor + const finalRegion = this.region || region || DEFAULT_REGION + const requestOpt: RequestOption = { method, bucketName, headers } try {