unixfs.go 1.13 KB
Newer Older
1 2 3 4 5
package iface

import (
	"context"

Łukasz Magiera's avatar
Łukasz Magiera committed
6
	"github.com/ipfs/go-ipfs/core/coreapi/interface/options"
7

8
	files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files"
Steven Allen's avatar
Steven Allen committed
9
	ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format"
10 11
)

12 13
type AddEvent struct {
	Name  string
14 15 16
	Path  ResolvedPath `json:",omitempty"`
	Bytes int64        `json:",omitempty"`
	Size  string       `json:",omitempty"`
17 18
}

19
// UnixfsAPI is the basic interface to immutable files in IPFS
20
// NOTE: This API is heavily WIP, things are guaranteed to break frequently
21 22
type UnixfsAPI interface {
	// Add imports the data from the reader into merkledag file
Łukasz Magiera's avatar
Łukasz Magiera committed
23 24
	//
	// TODO: a long useful comment on how to use this for many different scenarios
25
	Add(context.Context, files.Node, ...options.UnixfsAddOption) (ResolvedPath, error)
26

Łukasz Magiera's avatar
Łukasz Magiera committed
27 28 29 30
	// Get returns a read-only handle to a file tree referenced by a path
	//
	// Note that some implementations of this API may apply the specified context
	// to operations performed on the returned file
31
	Get(context.Context, Path) (files.Node, error)
Łukasz Magiera's avatar
Łukasz Magiera committed
32

33 34 35
	// Ls returns the list of links in a directory
	Ls(context.Context, Path) ([]*ipld.Link, error)
}