client

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIPFSAPIAddress

func GetIPFSAPIAddress(ipfsPath string, scheme string) (string, error)

GetIPFSAPIAddress get IPFS API URL from the specified IPFS repository. If ipfsPath == "", then it's default is "~/.ipfs". This is compatible to IPFS client behaviour: https://github.com/ipfs/go-ipfs-http-client/blob/171fcd55e3b743c38fb9d78a34a3a703ee0b5e89/api.go#L69-L81

Types

type Client

type Client struct {
	// Address is URL of IPFS API to connect to.
	Address string

	// Client is http client to use for connecting to IPFS API
	Client *http.Client
}

Client is an IPFS API client.

func New

func New(ipfsAPIAddress string) *Client

New creates a new IPFS API client of the specified address.

func (*Client) Add

func (c *Client) Add(r io.Reader) (cidv1 string, retErr error)

Add adds the provided data to IPFS and returns its CID (v1).

func (*Client) Get

func (c *Client) Get(p string, offset *int, length *int) (_ io.ReadCloser, retErr error)

Get get the reader of the data specified by the IPFS path and optionally with the offset and length.

func (*Client) StatCID

func (c *Client) StatCID(cid string) (info *FileInfo, retErr error)

StatCID gets and returns information of the file specified by the cid.

type FileInfo

type FileInfo struct {
	Blocks         int    `json:"Blocks"`
	CumulativeSize uint64 `json:"CumulativeSize"`
	Hash           string `json:"Hash"`
	Local          bool   `json:"Local"`
	Size           uint64 `json:"Size"`
	SizeLocal      uint64 `json:"SizeLocal"`
	Type           string `json:"Type"`
	WithLocality   bool   `json:"WithLocality"`
}

FileInfo represents the information provided by "/api/v0/files/stat" API of IPFS. Please see details at: https://docs.ipfs.tech/reference/kubo/rpc/#api-v0-files-stat

Jump to

Keyboard shortcuts

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