go-w3s-client
A client to the Web3.Storage API.
Demo: https://youtu.be/FLsQZ_ogeOg
Install
go get github.com/web3-storage/go-w3s-client
Usage
package main
import (
"io/fs"
"os"
"github.com/web3-storage/go-w3s-client"
)
func main() {
c, _ := w3s.NewClient(w3s.WithToken("<AUTH_TOKEN>"))
f, _ := os.Open("images/pinpie.jpg")
cid, _ := c.Put(context.Background(), f)
fmt.Printf("https://%v.ipfs.dweb.link\n", cid)
res, _ := c.Get(context.Background(), cid)
f, fsys, _ := res.Files()
if d, ok := f.(fs.ReadDirFile); ok {
ents, _ := d.ReadDir(0)
for _, ent := range ents {
fmt.Println(ent.Name())
}
}
fs.WalkDir(fsys, "/", func(path string, d fs.DirEntry, err error) error {
info, _ := d.Info()
fmt.Printf("%s (%d bytes)\n", path, info.Size())
return err
})
img, _ := fsys.Open("pinpie.jpg")
}
See example for more.
API
pkg.go.dev Reference
Contribute
Feel free to dive in! Open an issue or submit PRs.
License
Dual-licensed under MIT + Apache 2.0