1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| package main
import ( "context" "fmt" "github.com/ipfs/boxo/files" "github.com/ipfs/boxo/path" "github.com/ipfs/kubo/client/rpc" ma "github.com/multiformats/go-multiaddr" "net/http" "os" )
func main() { address, err := ma.NewMultiaddr("/ip4/192.168.123.6/tcp/4001") if err != nil { fmt.Println(err) }
node, err := rpc.NewApiWithClient(address, &http.Client{}) if err != nil { fmt.Println(err) return } ctx := context.Background() cid := "/ipfs/QmepEzGBkDQ7a8xCTVYZvuZL2C7FUxaaC75FSY8pGb1v7b" p, err := path.NewPath(cid) if err != nil { fmt.Println(err) } data, err := node.Object().Get(ctx, p)
if err != nil { fmt.Println(err) return } fmt.Println(string(data.RawData())) return }
func getFile() {
}
func putFile() { node, err := rpc.NewLocalApi() if err != nil { fmt.Println(err) return } ctx := context.Background()
f, _ := os.Open("/Users/qxdo/Projects/make_order/test.html") fmt.Println(node.Unixfs().Add(ctx, files.NewReaderFile(f))) }
|