1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-18 05:31:35 +08:00
Files
Ho-Sheng Hsiao bf22aeec0a Reorged imports from jbenet/go-ipfs to ipfs/go-ipfs
- Modified Godeps/Godeps.json by hand
- [TEST] Updated welcome docs hash to sharness
- [TEST] Updated contact doc
- [TEST] disabled breaking test (t0080-repo refs local)
2015-03-31 12:52:25 -07:00

48 lines
1.4 KiB
Go

package s3datastore
import (
"errors"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/crowdmob/goamz/s3"
datastore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
)
var _ datastore.ThreadSafeDatastore = &S3Datastore{}
var errTODO = errors.New("TODO")
var ErrInvalidType = errors.New("s3 datastore: invalid type error")
type S3Datastore struct {
Client *s3.S3
Bucket string
}
func (ds *S3Datastore) Put(key datastore.Key, value interface{}) (err error) {
data, ok := value.([]byte)
if !ok {
return ErrInvalidType
}
// TODO extract perms and s3 options
return ds.Client.Bucket(ds.Bucket).Put(key.String(), data, "application/protobuf", s3.PublicRead, s3.Options{})
}
func (ds *S3Datastore) Get(key datastore.Key) (value interface{}, err error) {
return ds.Client.Bucket(ds.Bucket).Get(key.String())
}
func (ds *S3Datastore) Has(key datastore.Key) (exists bool, err error) {
return ds.Client.Bucket(ds.Bucket).Exists(key.String())
}
func (ds *S3Datastore) Delete(key datastore.Key) (err error) {
return ds.Client.Bucket(ds.Bucket).Del(key.String())
}
func (ds *S3Datastore) Query(q query.Query) (query.Results, error) {
return nil, errors.New("TODO implement query for s3 datastore?")
}
func (ds *S3Datastore) IsThreadSafe() {}