Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(737)

Delta Between Two Patch Sets: s3/s3.go

Issue 6343080: s3: fix regions that require lowercase buckets. (Closed)
Left Patch Set: Created 12 years, 9 months ago
Right Patch Set: s3: fix regions that require lowercase buckets. Created 12 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « aws/aws.go ('k') | s3/s3i_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // 1 //
2 // goamz - Go packages to interact with the Amazon Web Services. 2 // goamz - Go packages to interact with the Amazon Web Services.
3 // 3 //
4 // https://wiki.ubuntu.com/goamz 4 // https://wiki.ubuntu.com/goamz
5 // 5 //
6 // Copyright (c) 2011 Canonical Ltd. 6 // Copyright (c) 2011 Canonical Ltd.
7 // 7 //
8 // Written by Gustavo Niemeyer <gustavo.niemeyer@canonical.com> 8 // Written by Gustavo Niemeyer <gustavo.niemeyer@canonical.com>
9 // 9 //
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 DisplayName string 47 DisplayName string
48 } 48 }
49 49
50 // New creates a new S3. 50 // New creates a new S3.
51 func New(auth aws.Auth, region aws.Region) *S3 { 51 func New(auth aws.Auth, region aws.Region) *S3 {
52 return &S3{auth, region, 0} 52 return &S3{auth, region, 0}
53 } 53 }
54 54
55 // Bucket returns a Bucket with the given name. 55 // Bucket returns a Bucket with the given name.
56 func (s3 *S3) Bucket(name string) *Bucket { 56 func (s3 *S3) Bucket(name string) *Bucket {
57 » // Some regions outside the US do not permit upper case bucket names, as 57 » if s3.Region.S3BucketEndpoint != "" || s3.Region.S3LowercaseBucket {
58 » // they cannot be legal domain name components. 58 » » name = strings.ToLower(name)
59 » return &Bucket{s3, strings.ToLower(name)} 59 » }
60 » return &Bucket{s3, name}
60 } 61 }
61 62
62 var createBucketConfiguration = `<CreateBucketConfiguration xmlns="http://s3.ama zonaws.com/doc/2006-03-01/">· 63 var createBucketConfiguration = `<CreateBucketConfiguration xmlns="http://s3.ama zonaws.com/doc/2006-03-01/">·
63 <LocationConstraint>%s</LocationConstraint>· 64 <LocationConstraint>%s</LocationConstraint>·
64 </CreateBucketConfiguration>` 65 </CreateBucketConfiguration>`
65 66
66 // locationConstraint returns an io.Reader specifying a LocationConstraint if· 67 // locationConstraint returns an io.Reader specifying a LocationConstraint if·
67 // required for the region. 68 // required for the region.
68 // 69 //
69 // See http://goo.gl/bh9Kq for more details. 70 // See http://goo.gl/bh9Kq for more details.
70 func (s3 *S3) locationConstraint() io.Reader { 71 func (s3 *S3) locationConstraint() io.Reader {
71 constraint := "" 72 constraint := ""
72 » if s3.Region.Name != aws.USEast.Name { 73 » if s3.Region.S3LocationConstraint {
73 » » // CreateBucketConfiguration is manditory for non us-east-1, but
74 » » // forbidden for us-east-1.
75 constraint = fmt.Sprintf(createBucketConfiguration, s3.Region.Na me) 74 constraint = fmt.Sprintf(createBucketConfiguration, s3.Region.Na me)
76 } 75 }
77 return strings.NewReader(constraint) 76 return strings.NewReader(constraint)
78 } 77 }
79 78
80 type ACL string 79 type ACL string
81 80
82 const ( 81 const (
83 Private = ACL("private") 82 Private = ACL("private")
84 PublicRead = ACL("public-read") 83 PublicRead = ACL("public-read")
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 r.Body.Close() 487 r.Body.Close()
489 err.StatusCode = r.StatusCode 488 err.StatusCode = r.StatusCode
490 if err.Message == "" { 489 if err.Message == "" {
491 err.Message = r.Status 490 err.Message = r.Status
492 } 491 }
493 if debug { 492 if debug {
494 log.Printf("err: %#v\n", err) 493 log.Printf("err: %#v\n", err)
495 } 494 }
496 return &err 495 return &err
497 } 496 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b