Skip to content

Commit

Permalink
fix use configured region from constructor for makebucket
Browse files Browse the repository at this point in the history
  • Loading branch information
prakashsvmx committed May 13, 2024
1 parent fd89297 commit bbafeda
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions examples/make-bucket.js → examples/make-bucket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
7 changes: 3 additions & 4 deletions src/internal/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit bbafeda

Please sign in to comment.