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:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user