ipfsdriver

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DriverName = "ipfs"
)

Variables

This section is empty.

Functions

func NewDriverFromParams

func NewDriverFromParams(params DriverParameters) (storagedriver.StorageDriver, error)

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

type DriverParameters

type DriverParameters struct {
	// IpfsApiAddress is the address of the ipfs node's api port.
	// In multi address format.
	// `ipfsapiaddress` in the yaml
	IpfsApiAddress string
	// IPNS key to write to our MFS root to. `writeipnskey` in yaml.
	WriteIpnsKey string

	// Optional list of IPNS keys to read other MFS roots.
	// This allows you to specify the IPNS key of a remote node, and
	// share the images of that node. Thus enabling p2p registries.
	// `readonlyipnskeys` in yaml.
	ReadOnlyKeys []string
}

type IpfsDriver

type IpfsDriver struct {
	// contains filtered or unexported fields
}

IpfsDriver implements the storagedriver.StorageDriver interface

func NewDriverFromAPI

func NewDriverFromAPI(ctx context.Context, api coreapi.CoreAPI, ipnsKeyWrite string, ipnsKeyReadOnly []string) (readydriver *IpfsDriver, err error)

func (*IpfsDriver) Close

func (s *IpfsDriver) Close() error

func (*IpfsDriver) Delete

func (s *IpfsDriver) Delete(ctx context.Context, path string) error

Delete recursively deletes all objects stored at "path" and its subpaths.

func (*IpfsDriver) GetContent

func (s *IpfsDriver) GetContent(ctx context.Context, path string) ([]byte, error)

GetContent retrieves the content stored at "path" as a []byte. This should primarily be used for small objects.

func (*IpfsDriver) List

func (s *IpfsDriver) List(ctx context.Context, subPath string) ([]string, error)

List returns a list of the objects that are direct descendants of the given path.

func (*IpfsDriver) Move

func (s *IpfsDriver) Move(ctx context.Context, sourcePath string, destPath string) error

Move moves an object stored at sourcePath to destPath, removing the original object. Note: This may be no more efficient than a copy followed by a delete for many implementations.

func (*IpfsDriver) Name

func (s *IpfsDriver) Name() string

Name returns the human-readable "name" of the driver, useful in error messages and logging. By convention, this will just be the registration name, but drivers may provide other information here.

func (*IpfsDriver) PutContent

func (s *IpfsDriver) PutContent(ctx context.Context, path string, content []byte) (retErr error)

PutContent stores the []byte content at a location designated by "path". This should primarily be used for small objects.

func (*IpfsDriver) Reader

func (s *IpfsDriver) Reader(ctx context.Context, path string, offset int64) (io.ReadCloser, error)

Reader retrieves an io.ReadCloser for the content stored at "path" with a given byte offset. May be used to resume reading a stream by providing a nonzero offset.

func (*IpfsDriver) Stat

Stat retrieves the FileInfo for the given path, including the current size in bytes and the creation time.

func (*IpfsDriver) URLFor

func (s *IpfsDriver) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error)

URLFor returns a URL which may be used to retrieve the content stored at the given path, possibly using the given options. May return an ErrUnsupportedMethod in certain StorageDriver implementations.

func (*IpfsDriver) Walk

func (s *IpfsDriver) Walk(ctx context.Context, path string, f storagedriver.WalkFn) error

Walk traverses a filesystem defined within driver, starting from the given path, calling f on each file. If the returned error from the WalkFn is ErrSkipDir and fileInfo refers to a directory, the directory will not be entered and Walk will continue the traversal. If fileInfo refers to a normal file, processing stops

func (*IpfsDriver) Writer

func (s *IpfsDriver) Writer(ctx context.Context, path string, append bool) (w storagedriver.FileWriter, retErr error)

Writer returns a FileWriter which will store the content written to it at the location designated by "path" after the call to Commit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL