Skip to content
This repository was archived by the owner on Oct 5, 2023. It is now read-only.

docs: adding example of connection and pinning to README #173

Merged
merged 6 commits into from
Mar 28, 2023
Merged
Changes from all commits
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
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,41 @@ greatest features, please use _this_ package.

https://godoc.org/github.com/ipfs/go-ipfs-http-api

### Example

Pin file on your local IPFS node based on its CID:

```go
package main

import (
"context"
"fmt"

ipfsClient "github.com/ipfs/go-ipfs-http-client"
path "github.com/ipfs/interface-go-ipfs-core/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
}
```

## Contribute

Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/go-ipfs-http-api/issues)!
Expand Down