thirdparty/s3-datastore: Let caller set ACL, change default to safer "private"
License: MIT Signed-off-by: Tommi Virtanen <tv@eagain.net>
Tommi Virtanen committed
May 20, 2015 at 14:20 UTC
1174aab86bddbde3d88e99fb922cb6f692e8f95a
1 file changed
+7
-2
thirdparty/s3-datastore/datastore.go
+7
-2
@@ -18,6 +18,7 @@ var ErrInvalidType = errors.New("s3 datastore: invalid type error")
18
type S3Datastore struct {
19
Client *s3.S3
20
Bucket string
21
+ ACL s3.ACL
22
}
23
24
func (ds *S3Datastore) encode(key datastore.Key) string {
@@ -37,10 +38,14 @@ func (ds *S3Datastore) Put(key datastore.Key, value interface{}) (err error) {
38
if !ok {
39
return ErrInvalidType
40
}
40
- // TODO extract perms and s3 options
41
+ // TODO extract s3 options
42
43
k := ds.encode(key)
43
- return ds.Client.Bucket(ds.Bucket).Put(k, data, "application/protobuf", s3.PublicRead, s3.Options{})
44
+ acl := ds.ACL
45
+ if acl == "" {
46
+ acl = s3.Private
47
+ }
48
+ return ds.Client.Bucket(ds.Bucket).Put(k, data, "application/protobuf", acl, s3.Options{})
49
}
50
51
func (ds *S3Datastore) Get(key datastore.Key) (value interface{}, err error) {