@cryptotaxi247 / kubo / commits / 45deffe50

go-ipfs-config: S3 datastore support

To test it, set up an S3 bucket (in an AWS region that is not US Standard, for read-after-write consistency), run `ipfs init`, then edit `~/.ipfs/config` to say "Datastore": { "Type": "s3", "Region": "us-west-1", "Bucket": "mahbukkit", "ACL": "private" }, with the right values. Set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` in the environment and you should be able to run `ipfs add` and `ipfs cat` and see the bucket be populated. No automated tests exist, unfortunately. S3 is thorny to simulate. License: MIT Signed-off-by: Tommi Virtanen <tv@eagain.net>

Tommi Virtanen committed May 20, 2015 at 14:32 UTC 45deffe50ea5823bd59c1d3ef412a4aac7c93402
1 file changed +20
config/datastore.go
+20
@@ -1,5 +1,9 @@
1 package config
2
3 +import (
4 + "encoding/json"
5 +)
6 +
7 // DefaultDataStoreDirectory is the directory to store all the local IPFS data.
8 const DefaultDataStoreDirectory = "datastore"
9
@@ -10,6 +14,22 @@ type Datastore struct {
14 StorageMax string // in B, kB, kiB, MB, ...
15 StorageGCWatermark int64 // in percentage to multiply on StorageMax
16 GCPeriod string // in ns, us, ms, s, m, h
17 +
18 + Params *json.RawMessage
19 +}
20 +
21 +func (d *Datastore) ParamData() []byte {
22 + if d.Params == nil {
23 + return nil
24 + }
25 +
26 + return []byte(*d.Params)
27 +}
28 +
29 +type S3Datastore struct {
30 + Region string `json:"region"`
31 + Bucket string `json:"bucket"`
32 + ACL string `json:"acl"`
33 }
34
35 // DataStorePath returns the default data store path given a configuration root