mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-10-31 01:58:11 +08:00
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
This commit is contained in:
@ -507,20 +507,12 @@ func (this S3Backend) createSession(bucket string) *session.Session {
|
|||||||
for k, v := range this.params {
|
for k, v := range this.params {
|
||||||
newParams[k] = v
|
newParams[k] = v
|
||||||
}
|
}
|
||||||
c := S3Cache.Get(newParams)
|
if c := S3Cache.Get(newParams); c == nil {
|
||||||
if c == nil {
|
if res, err := this.client.GetBucketLocation(&s3.GetBucketLocationInput{
|
||||||
res, err := this.client.GetBucketLocation(&s3.GetBucketLocationInput{
|
|
||||||
Bucket: aws.String(bucket),
|
Bucket: aws.String(bucket),
|
||||||
})
|
}); err == nil && res.LocationConstraint != nil {
|
||||||
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
|
this.config.Region = res.LocationConstraint
|
||||||
}
|
}
|
||||||
}
|
|
||||||
S3Cache.Set(newParams, this.config.Region)
|
S3Cache.Set(newParams, this.config.Region)
|
||||||
} else {
|
} else {
|
||||||
this.config.Region = c.(*string)
|
this.config.Region = c.(*string)
|
||||||
|
|||||||
Reference in New Issue
Block a user