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

import (
	"context"

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

8
	files "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit/files"
9
	ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format"
10 11
)

12 13 14 15 16 17 18 19
// 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"`
}

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

Łukasz Magiera's avatar
Łukasz Magiera committed
28 29 30 31 32 33
	// 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
	Get(context.Context, Path) (files.File, error)

34
	// Cat returns a reader for the file
35
	// TODO: Remove in favour of Get (if we use Get on a file we still have reader directly, so..)
36 37 38 39 40
	Cat(context.Context, Path) (Reader, error)

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