mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
| .. | ||
| api_test.go | ||
| api.go | ||
| apifile.go | ||
| block.go | ||
| dag.go | ||
| dht.go | ||
| errors_test.go | ||
| errors.go | ||
| key.go | ||
| name.go | ||
| object.go | ||
| path.go | ||
| pin.go | ||
| pubsub.go | ||
| README.md | ||
| request.go | ||
| requestbuilder.go | ||
| response.go | ||
| routing.go | ||
| swarm.go | ||
| unixfs.go | ||
httpapi
IPFS CoreAPI implementation using HTTP API
This packages implements coreiface.CoreAPI over the HTTP API.
Documentation
https://pkg.go.dev/github.com/ipfs/kubo/client/rpc
Example
Pin file on your local IPFS node based on its CID:
package main
import (
"context"
"fmt"
ipfsClient "github.com/ipfs/kubo/client/rpc"
path "github.com/ipfs/boxo/coreiface/path"
)
func main() {
// "Connect" to local node
node, err := ipfsClient.NewLocalApi()
if err != nil {
fmt.Printf(err)
return
}
// Pin a given file by its CID
ctx := context.Background()
cid := "bafkreidtuosuw37f5xmn65b3ksdiikajy7pwjjslzj2lxxz2vc4wdy3zku"
p := path.New(cid)
err = node.Pin().Add(ctx, p)
if err != nil {
fmt.Printf(err)
return
}
return
}