1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-20 19:19:06 +08:00

thirdparty/s3-datastore: Let caller set ACL, change default to safer "private"

License: MIT
Signed-off-by: Tommi Virtanen <tv@eagain.net>
This commit is contained in:
Tommi Virtanen
2015-05-20 14:20:33 -07:00
committed by Jeromy
parent 33d41285d6
commit 1174aab86b

View File

@ -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) {