From d5628fd03dda2d96dec84a652d8fa0d420edb68c Mon Sep 17 00:00:00 2001 From: MickaelK Date: Mon, 12 May 2025 21:05:15 +1000 Subject: [PATCH] fix (s3): region issue on s3 for server like versitygw which as of today doesn't support getBucketLocation, we'd be sending the wrong region through --- server/plugin/plg_backend_s3/index.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/server/plugin/plg_backend_s3/index.go b/server/plugin/plg_backend_s3/index.go index 256a5573..f85be443 100644 --- a/server/plugin/plg_backend_s3/index.go +++ b/server/plugin/plg_backend_s3/index.go @@ -507,19 +507,11 @@ func (this S3Backend) createSession(bucket string) *session.Session { for k, v := range this.params { newParams[k] = v } - c := S3Cache.Get(newParams) - if c == nil { - res, err := this.client.GetBucketLocation(&s3.GetBucketLocationInput{ + if c := S3Cache.Get(newParams); c == nil { + if res, err := this.client.GetBucketLocation(&s3.GetBucketLocationInput{ Bucket: aws.String(bucket), - }) - if err != nil { - this.config.Region = aws.String("us-east-1") - } else { - if res.LocationConstraint == nil { - this.config.Region = aws.String("us-east-1") - } else { - this.config.Region = res.LocationConstraint - } + }); err == nil && res.LocationConstraint != nil { + this.config.Region = res.LocationConstraint } S3Cache.Set(newParams, this.config.Region) } else {