Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IPFS example #12

Merged
merged 4 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [Create fs Storager](new_fs.go)
- [Create s3 Storager](new_s3.go) (Amazon S3)
- [Create cos Storager](new_cos.go) (Tencent Cloud Object Storage)
- [Create ipfs Storager](new_ipfs.go) (InterPlanetary File System)
- [Read a file](read.go)
- [Read a range of a file](read.go)
- [Read a file with callback](read.go)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.15
require (
github.com/beyondstorage/go-service-cos/v2 v2.1.0
github.com/beyondstorage/go-service-fs/v3 v3.2.0
github.com/beyondstorage/go-service-ipfs v0.0.0-20210630034409-8cf084ff7941
Xuanwo marked this conversation as resolved.
Show resolved Hide resolved
github.com/beyondstorage/go-service-s3/v2 v2.2.0
github.com/beyondstorage/go-storage/v4 v4.2.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/beyondstorage/go-service-cos/v2 v2.1.0 h1:XzwhZkKGPesR4pNuzXgJf07wLs6
github.com/beyondstorage/go-service-cos/v2 v2.1.0/go.mod h1:tMtLHM91wGhcs3SNyrgcIflkDyvC+6KBBkTC+TIxlJo=
github.com/beyondstorage/go-service-fs/v3 v3.2.0 h1:POC1Z9b7Z6dTQycPnEsjRVtq7PndFInHzsP/A1Y9T+0=
github.com/beyondstorage/go-service-fs/v3 v3.2.0/go.mod h1:dHLOhJtn8Uh1WGuL5m6DN9/ZtWbBFD+CKRhga535wkY=
github.com/beyondstorage/go-service-ipfs v0.0.0-20210630034409-8cf084ff7941 h1:l4HJlF0YR2oKhJ82+0dVcacZ6+zDPPFsK3AKA2wHP58=
github.com/beyondstorage/go-service-ipfs v0.0.0-20210630034409-8cf084ff7941/go.mod h1:07OYrRVyYl0cWB/4HWD/Aar0K0JaAu+mpiTfzC7CbHo=
github.com/beyondstorage/go-service-s3/v2 v2.2.0 h1:aAQa4yXMb1AoeZWaQI5bhDbKARSbg/avRb0yu09Wlrc=
github.com/beyondstorage/go-service-s3/v2 v2.2.0/go.mod h1:R5W0FHPt6RmFAEO/ngoJ04q3G/i+mb38GCJNPZPwtxc=
github.com/beyondstorage/go-storage/v4 v4.2.0 h1:J0xqqy4qEQRtIS2zUWMA5wRXVHx/cxX5fHsU2ezA3+I=
Expand Down
22 changes: 22 additions & 0 deletions new_ipfs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package example

import (
"os"

ipfs "github.com/beyondstorage/go-service-ipfs"
"github.com/beyondstorage/go-storage/v4/pairs"
"github.com/beyondstorage/go-storage/v4/types"
)

func NewIPFS() (types.Storager, error) {
return ipfs.NewStorager(
// work_dir: https://beyondstorage.io/docs/go-storage/pairs/work_dir
//
// Relative operations will be based on this WorkDir.
pairs.WithWorkDir(os.Getenv("STORAGE_IPFS_WORKDIR")),
// endpoint: https://beyondstorage.io/docs/go-storage/pairs/endpoint
//
// Example Value: https:host:port
pairs.WithEndpoint(os.Getenv("STORAGE_IPFS_ENDPOINT")),
)
}