docs for coreapi unixfs method impls
License: MIT Signed-off-by: ForrestWeston <forrest@protocol.ai>
ForrestWeston committed
Jan 22, 2018 at 14:47 UTC
8637bbce9e4a2b887818b7cc529f22dded0e6d59
1 file changed
+5
core/coreapi/unixfs.go
+5
@@ -14,6 +14,8 @@ import (
14
15
type UnixfsAPI CoreAPI
16
17
+// Add builds a merkledag node from a reader, adds it to the blockstore,
18
+// and returns the key representing that node.
19
func (api *UnixfsAPI) Add(ctx context.Context, r io.Reader) (coreiface.Path, error) {
20
k, err := coreunix.AddWithContext(ctx, api.node, r)
21
if err != nil {
@@ -26,6 +28,7 @@ func (api *UnixfsAPI) Add(ctx context.Context, r io.Reader) (coreiface.Path, err
28
return ParseCid(c), nil
29
}
30
31
+// Cat returns the data contained by an IPFS or IPNS object(s) at path `p`.
32
func (api *UnixfsAPI) Cat(ctx context.Context, p coreiface.Path) (coreiface.Reader, error) {
33
dagnode, err := api.core().ResolveNode(ctx, p)
34
if err != nil {
@@ -41,6 +44,8 @@ func (api *UnixfsAPI) Cat(ctx context.Context, p coreiface.Path) (coreiface.Read
44
return r, nil
45
}
46
47
+// Ls returns the contents of an IPFS or IPNS object(s) at path p, with the format:
48
+// `<link base58 hash> <link size in bytes> <link name>`
49
func (api *UnixfsAPI) Ls(ctx context.Context, p coreiface.Path) ([]*coreiface.Link, error) {
50
dagnode, err := api.core().ResolveNode(ctx, p)
51
if err != nil {