unixfs.go 1.07 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
)

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

Łukasz Magiera's avatar
Łukasz Magiera committed
20 21 22 23 24 25
	// 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)

26 27 28 29 30 31
	// Cat returns a reader for the file
	Cat(context.Context, Path) (Reader, error)

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