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

import (
	"context"
5
	"io"
6

7 8
	options "github.com/ipfs/go-ipfs/core/coreapi/interface/options"

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

13 14 15 16 17 18 19 20
// TODO: ideas on making this more coreapi-ish without breaking the http API?
type AddEvent struct {
	Name  string
	Hash  string `json:",omitempty"`
	Bytes int64  `json:",omitempty"`
	Size  string `json:",omitempty"`
}

21 22 23 24 25
type UnixfsFile interface {
	files.SizeFile
	io.Seeker
}

26
// UnixfsAPI is the basic interface to immutable files in IPFS
27
// NOTE: This API is heavily WIP, things are guaranteed to break frequently
28 29
type UnixfsAPI interface {
	// Add imports the data from the reader into merkledag file
Łukasz Magiera's avatar
Łukasz Magiera committed
30 31
	//
	// TODO: a long useful comment on how to use this for many different scenarios
32
	Add(context.Context, files.File, ...options.UnixfsAddOption) (ResolvedPath, error)
33

Łukasz Magiera's avatar
Łukasz Magiera committed
34 35 36 37
	// 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
38
	Get(context.Context, Path) (UnixfsFile, error)
Łukasz Magiera's avatar
Łukasz Magiera committed
39

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