ipfs

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Remote mode = iota // Store files to pinning service
	Local              // Store file on local IPFS node

)

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerFunc

type HandlerFunc func(Pinner, interface{}) (string, error)

The HandlerFunc type is an adapter to allow the use of ordinary functions as IPFS handlers.

type Locally

type Locally struct {
	Pinning
}

func (*Locally) Pin

func (l *Locally) Pin(buf []byte) (cid string, err error)

Pin implements putting the data to local IPFS node by given buf. It returns content-id and an error.

func (*Locally) PinDir

func (l *Locally) PinDir(path string) (cid string, err error)

Pin implements putting the data to local IPFS node by given buf. It returns content-id and an error.

type Pinner

type Pinner interface {
	// Pin implements data transmission to the destination service by given buf. It
	// returns the content-id returned by the local IPFS server or a remote pinning service.
	Pin(buf []byte) (string, error)

	// Pin implements directory transmission to the destination service by given path. It
	// returns the content-id returned by the local IPFS server or a remote pinning service.
	PinDir(path string) (string, error)
}

Pinner is an interface that wraps the Pin method.

type Pinning

type Pinning struct {
	// It supports both daemon server and remote pinner, defaults to remote pinner.
	Mode mode

	Host string
	Port int

	// For pinner mode, which normally requires the apikey and secret of the pinning service.
	Pinner string
	Apikey string
	Secret string
	// contains filtered or unexported fields
}

Pinning provides the configuration of pinning services that will be utilized for data storage.

func Options

func Options(options ...PinningOption) Pinning

type PinningOption

type PinningOption func(*Pinning)

func Apikey

func Apikey(k string) PinningOption

func Host

func Host(h string) PinningOption

func Mode

func Mode(m mode) PinningOption

func Port

func Port(p int) PinningOption

func Secret

func Secret(s string) PinningOption

func Uses

func Uses(p string) PinningOption

type Remotely

type Remotely struct {
	Pinning
}

func (*Remotely) Pin

func (r *Remotely) Pin(buf []byte) (cid string, err error)

Pin implements putting the data to destination pinning service by given buf. It returns content-id and an error.

func (*Remotely) PinDir

func (r *Remotely) PinDir(path string) (cid string, err error)

Pin implements putting the data to destination pinning service by given buf. It returns content-id and an error.

Jump to

Keyboard shortcuts

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