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

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>
This commit is contained in:
Tommi Virtanen
2015-05-20 14:32:23 -07:00
committed by Jeromy
parent 1174aab86b
commit 8f2d820412
5 changed files with 79 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package fsrepo
import (
"encoding/json"
"errors"
"fmt"
"io"
@ -331,6 +332,18 @@ func (r *FSRepo) openDatastore() error {
return err
}
r.ds = d
case "s3":
var dscfg config.S3Datastore
if err := json.Unmarshal(r.config.Datastore.ParamData(), &dscfg); err != nil {
return fmt.Errorf("datastore s3: %v", err)
}
ds, err := openS3Datastore(dscfg)
if err != nil {
return err
}
r.ds = ds
default:
return fmt.Errorf("unknown datastore type: %s", r.config.Datastore.Type)
}