Merge lp:~scalia/goamz/add-content-encoding into lp:goamz

Proposed by Antonio Nicolás Pina
Status: Needs review
Proposed branch: lp:~scalia/goamz/add-content-encoding
Merge into: lp:goamz
Diff against target: 56 lines (+31/-3)
2 files modified
s3/s3.go (+12/-3)
s3/s3_test.go (+19/-0)
To merge this branch: bzr merge lp:~scalia/goamz/add-content-encoding
Reviewer Review Type Date Requested Status
goamz maintainers Pending
Review via email: mp+222776@code.launchpad.net

Description of the change

Added a method to indicate the content-encoding of a file in S3.

To post a comment you must log in.
49. By Antonio Nicolás Pina <email address hidden>

Added test for the new function.

Revision history for this message
Dimiter Naydenov (dimitern) wrote :

@scalia can you re-propose this against http://github.com/go-amz/amz ?

Unmerged revisions

49. By Antonio Nicolás Pina <email address hidden>

Added test for the new function.

48. By Antonio Nicolás Pina <email address hidden>

Added a method to indicate the content-encoding of a file in S3.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 's3/s3.go'
2--- s3/s3.go 2014-02-12 13:42:33 +0000
3+++ s3/s3.go 2014-06-11 10:23:55 +0000
4@@ -191,10 +191,19 @@
5 // PutReader inserts an object into the S3 bucket by consuming data
6 // from r until EOF.
7 func (b *Bucket) PutReader(path string, r io.Reader, length int64, contType string, perm ACL) error {
8+ return b.PutReaderEncoding(path, r, length, contType, perm, "")
9+}
10+
11+// PutReaderEncoding inserts an object into the S3 bucket by consuming data
12+// from r until EOF with a Content-Encoding header.
13+func (b *Bucket) PutReaderEncoding(path string, r io.Reader, length int64, contType string, perm ACL, contEncoding string) error {
14 headers := map[string][]string{
15- "Content-Length": {strconv.FormatInt(length, 10)},
16- "Content-Type": {contType},
17- "x-amz-acl": {string(perm)},
18+ "Content-Length": {strconv.FormatInt(length, 10)},
19+ "Content-Type": {contType},
20+ "x-amz-acl": {string(perm)},
21+ }
22+ if "" != contEncoding {
23+ headers["Content-Encoding"] = []string{contEncoding}
24 }
25 req := &request{
26 method: "PUT",
27
28=== modified file 's3/s3_test.go'
29--- s3/s3_test.go 2013-08-15 13:18:02 +0000
30+++ s3/s3_test.go 2014-06-11 10:23:55 +0000
31@@ -191,6 +191,25 @@
32 c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
33 }
34
35+func (s *S) TestPutReaderEncoding(c *C) {
36+ testServer.Response(200, nil, "")
37+
38+ b := s.s3.Bucket("bucket")
39+ buf := bytes.NewBufferString("content")
40+ err := b.PutReaderEncoding("name", buf, int64(buf.Len()), "content-type", s3.Private, "xz")
41+ c.Assert(err, IsNil)
42+
43+ req := testServer.WaitRequest()
44+ c.Assert(req.Method, Equals, "PUT")
45+ c.Assert(req.URL.Path, Equals, "/bucket/name")
46+ c.Assert(req.Header["Date"], Not(DeepEquals), []string{""})
47+ c.Assert(req.Header["Content-Type"], DeepEquals, []string{"content-type"})
48+ c.Assert(req.Header["Content-Length"], DeepEquals, []string{"7"})
49+ c.Assert(req.Header["Content-Encoding"], DeepEquals, []string{"xz"})
50+ //c.Assert(req.Header["Content-MD5"], Equals, "...")
51+ c.Assert(req.Header["X-Amz-Acl"], DeepEquals, []string{"private"})
52+}
53+
54 // DelObject docs: http://goo.gl/APeTt
55
56 func (s *S) TestDelObject(c *C) {

Subscribers

People subscribed via source and target branches

to all changes: