Add region to gcs gateway example

This commit is contained in:
Remco Verhoef
2017-05-10 16:53:44 -07:00
committed by Harshavardhana
parent 5c78415b31
commit 4430085981
2 changed files with 25 additions and 2 deletions
+21 -1
View File
@@ -222,8 +222,28 @@ func (l *gcsGateway) MakeBucket(bucket string) error {
func (l *gcsGateway) MakeBucketWithLocation(bucket, location string) error {
bkt := l.client.Bucket(bucket)
// this will map s3 regions to google multi regions
if v, ok := map[string]string{
"ap-northeast-1": "asia",
"ap-northeast-2": "asia",
"ap-south-1": "asia",
"ap-southeast-1": "asia",
"ap-southeast-2": "asia",
"eu-central-1": "eu",
"eu-west-1": "eu",
"eu-west-2": "eu",
"ca-central-1": "us",
"sa-east-1": "us",
"us-east-1": "us",
"us-east-2": "us",
"us-west-1": "us",
"us-west-2": "us",
}[location]; ok {
location = v
}
if err := bkt.Create(l.ctx, l.projectID, &storage.BucketAttrs{
Location: serverConfig.Region,
Location: location,
}); err != nil {
return gcsToObjectError(traceError(err), bucket)
}