From 1174aab86bddbde3d88e99fb922cb6f692e8f95a Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Wed, 20 May 2015 14:20:33 -0700 Subject: [PATCH] thirdparty/s3-datastore: Let caller set ACL, change default to safer "private" License: MIT Signed-off-by: Tommi Virtanen --- thirdparty/s3-datastore/datastore.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/thirdparty/s3-datastore/datastore.go b/thirdparty/s3-datastore/datastore.go index 981ab5415..5370cd876 100644 --- a/thirdparty/s3-datastore/datastore.go +++ b/thirdparty/s3-datastore/datastore.go @@ -18,6 +18,7 @@ var ErrInvalidType = errors.New("s3 datastore: invalid type error") type S3Datastore struct { Client *s3.S3 Bucket string + ACL s3.ACL } func (ds *S3Datastore) encode(key datastore.Key) string { @@ -37,10 +38,14 @@ func (ds *S3Datastore) Put(key datastore.Key, value interface{}) (err error) { if !ok { return ErrInvalidType } - // TODO extract perms and s3 options + // TODO extract s3 options k := ds.encode(key) - return ds.Client.Bucket(ds.Bucket).Put(k, data, "application/protobuf", s3.PublicRead, s3.Options{}) + acl := ds.ACL + if acl == "" { + acl = s3.Private + } + return ds.Client.Bucket(ds.Bucket).Put(k, data, "application/protobuf", acl, s3.Options{}) } func (ds *S3Datastore) Get(key datastore.Key) (value interface{}, err error) {