Skip to content

Commit

Permalink
api: ListBuckets() should have a default region for AWS S3.
Browse files Browse the repository at this point in the history
Fixes #717
  • Loading branch information
harshavardhana authored and minio-trusted committed Jun 20, 2017
1 parent ce8164b commit fe6ec26
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,15 +558,24 @@ func (c Client) newRequest(method string, metadata requestMetadata) (req *http.R
method = "POST"
}

var location string
// Gather location only if bucketName is present.
if metadata.bucketName != "" && metadata.bucketLocation == "" {
location := metadata.bucketLocation
if metadata.bucketName != "" && location == "" {
// Gather location only if bucketName is present.
location, err = c.getBucketLocation(metadata.bucketName)
if err != nil {
return nil, err
}
} else {
location = metadata.bucketLocation
}
if location == "" {
// Default to location to 'us-east-1'.
location = "us-east-1"
if s3utils.IsAmazonChinaEndpoint(c.endpointURL) {
location = "cn-north-1"
} else if s3utils.IsAmazonGovCloudEndpoint(c.endpointURL) {
location = "us-gov-west-1"
} else if c.region != "" {
location = c.region
}
}

// Construct a new target URL.
Expand Down

0 comments on commit fe6ec26

Please sign in to comment.