w3s

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Overview

Package w3s provides a client to interact with the web3.storage API in the context of Git Annex remotes.

For a general purpose client see https://github.com/web3-storage/go-w3s-client

Index

Constants

View Source
const DefaultEndpoint = "https://api.web3.storage"

DefaultEndpoint is the default base URL for the web3.storage API. To use a different endpoint see the WithEndpoint function.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client for the web3.storage API for use by Git Annex remotes.

func New

func New(opts ...NewOpt) (*Client, error)

New creates a new Client with the given options. The only mandatory option is WithToken; the others have sensible defaults.

func (*Client) Equal

func (cl *Client) Equal(other *Client) bool

func (*Client) IsPresent

func (cl *Client) IsPresent(ctx context.Context, c cid.Cid) (bool, error)

func (*Client) Pin

func (cl *Client) Pin(ctx context.Context, c cid.Cid, key string) error

func (*Client) PutCar

func (cl *Client) PutCar(ctx context.Context, car *os.File, pro *progress.Tracker) (cid.Cid, error)

func (*Client) Unpin

func (cl *Client) Unpin(ctx context.Context, c cid.Cid) error

func (*Client) Upload

func (cl *Client) Upload(ctx context.Context, rdr fs.File, pro *progress.Tracker) (cid.Cid, error)

Upload stores the contents of rdr on web3.storage, returning the CID. TODO: rdr->fs.File? TODO: block until IsPinned is true? FIXME: progress tracking is broken because we convert to a CAR before uploading

type NewOpt

type NewOpt func(options *config) error

NewOpt is an option for the New() function.

func WithCanPin

func WithCanPin(can bool) NewOpt

WithCanPin is an option for the New() function which specifies whether the client is authorised to access the web3.storage PSA API; by default, this is false.

func WithEndpoint

func WithEndpoint(e string) NewOpt

WithEndpoint is an option for the New() function which sets the URL of the web3.storage endpoint. By default, DefaultEndpoint is used.

func WithHTTPClient

func WithHTTPClient(c *http.Client) NewOpt

WithHTTPClient is an option for the New() function which sets the http.Client with which to access the endpoint. By default, http.DefaultClient is used.

func WithTempDir

func WithTempDir(dir string) NewOpt

WithTempDir is an option for the New() function which specifies the temporary directory Upload() will use. By default, os.TempDir() is used.

func WithToken

func WithToken(tok string) NewOpt

WithToken is an option for the New() function which sets the JSON Web Token to authenticate with the endpoint.

Jump to

Keyboard shortcuts

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