1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-05-17 15:06:47 +08:00
Files
2024-05-26 11:04:40 +00:00
..
2023-10-06 16:14:44 +02:00
2023-11-29 12:29:59 +01:00
2023-11-29 12:29:59 +01:00
2024-03-25 09:59:47 +01:00
2023-12-04 09:51:26 +01:00
2023-11-29 12:29:59 +01:00
2023-11-29 12:29:59 +01:00
2023-11-29 12:29:59 +01:00
2023-11-29 12:29:59 +01:00

coreiface.CoreAPI over http rpc

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"

    "github.com/ipfs/kubo/client/rpc"
    path "github.com/ipfs/boxo/coreiface/path"
)

func main() {
    // "Connect" to local node
    node, err := rpc.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
}