util

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ThumbnailSize ImageSize = 100
	SmallSize               = 320
	MediumSize              = 800
	LargeSize               = 1600
)
View Source
const (
	ThumbnailPath ImagePath = "/thumb"
	SmallPath               = "/small"
	MediumPath              = "/medium"
	LargePath               = "/photo"
)

Variables

This section is empty.

Functions

func AddFileToDirectory

func AddFileToDirectory(ipfs *core.IpfsNode, dirb *uio.Directory, reader io.Reader, fname string) error

AddFileToDirectory adds bytes as file to a virtual directory (dag) structure

func DecodeExif

func DecodeExif(reader io.Reader) *exif.Exif

DecodeExif returns exif data from a reader if present

func EncodeImage

func EncodeImage(reader io.Reader, format Format, size ImageSize) ([]byte, error)

EncodeImage creates a jpeg|gif thumbnail from an image - jpeg quality is currently the default (75/100)

func GetArchiveAtPath

func GetArchiveAtPath(ipfs *core.IpfsNode, path string) (io.Reader, error)

GetArchiveAtPath builds an archive from directory links under an ipfs path NOTE: currently will bork if dir path contains other dirs (depth > 1)

func GetDataAtPath

func GetDataAtPath(ipfs *core.IpfsNode, path string) ([]byte, error)

GetDataAtPath return bytes under an ipfs path

func GetEncryptedReaderBytes

func GetEncryptedReaderBytes(reader io.Reader, key []byte) ([]byte, error)

GetEncryptedReaderBytes reads reader bytes and returns the encrypted result

func IdFromEncodedPublicKey

func IdFromEncodedPublicKey(key string) (peer.ID, error)

IdFromEncodedPublicKey return the underlying id from an encoded public key

func IdentityConfig

func IdentityConfig(sk libp2pc.PrivKey) (config.Identity, error)

IdentityConfig initializes a new identity.

func MultiaddrFromId

func MultiaddrFromId(id string) (ma.Multiaddr, error)

MultiaddrFromId creates a multiaddr from an id string

func ParsePeerParam

func ParsePeerParam(text string) (ma.Multiaddr, peer.ID, error)

ParsePeerParam takes a peer address string and returns p2p params

func PeersWithAddresses

func PeersWithAddresses(addrs []string) (pis []pstore.PeerInfo, err error)

PeersWithAddresses is a function that takes in a slice of string peer addresses (multiaddr + peerid) and returns a slice of properly constructed peers

func PinData

func PinData(ipfs *core.IpfsNode, data io.Reader) (*cid.Cid, error)

Data pins

func PinDirectory

func PinDirectory(ipfs *core.IpfsNode, dir ipld.Node, exclude []string) error

PinDirectory pins a directory exluding any provided links

func PinPath

func PinPath(ipfs *core.IpfsNode, path string, recursive bool) error

PinPath takes an ipfs path string and pins it

func PrintSwarmAddrs

func PrintSwarmAddrs(node *core.IpfsNode) error

PrintSwarmAddrs prints the addresses of the host

func PrivKeyFromMnemonic

func PrivKeyFromMnemonic(mnemonic *string) (libp2pc.PrivKey, string, error)

PrivKeyFromMnemonic creates a private key form a mnemonic phrase

func UnmarshalPrivateKeyFromString

func UnmarshalPrivateKeyFromString(key string) (libp2pc.PrivKey, error)

UnmarshalPrivateKeyFromString attempts to create a private key from a base64 encoded string

func UnmarshalPublicKeyFromString

func UnmarshalPublicKeyFromString(key string) (libp2pc.PubKey, error)

UnmarshalPublicKeyFromString attempts to create a public key from a base64 encoded string

func UnpinPath

func UnpinPath(ipfs *core.IpfsNode, path string) error

UnpinPath takes an ipfs path string and unpins it

Types

type FileMetadata

type FileMetadata struct {
	Metadata
	Name string `json:"name"`
	Ext  string `json:"extension"`
}

type Format

type Format string
const (
	JPEG Format = "jpeg"
	PNG  Format = "png"
	GIF  Format = "gif"
)

func DecodeImage

func DecodeImage(file *os.File) (*bytes.Reader, *Format, *image.Point, error)

DecodeImage returns a cleaned reader from an image file

type ImagePath

type ImagePath string

func ImagePathForSize

func ImagePathForSize(size ImageSize) ImagePath

type ImageSize

type ImageSize int

func ImageSizeForMinWidth

func ImageSizeForMinWidth(width int) ImageSize

type IpnsEntry

type IpnsEntry struct {
	Name  string
	Value string
}

func Publish

func Publish(ctx context.Context, n *core.IpfsNode, k libp2pc.PrivKey, ref path.Path, opts *PublishOpts) (*IpnsEntry, error)

type Metadata

type Metadata struct {
	Version string    `json:"version"`
	Created time.Time `json:"created,omitempty"`
	Added   time.Time `json:"added"`
}

type PhotoMetadata

type PhotoMetadata struct {
	FileMetadata
	Width          int     `json:"width"`
	Height         int     `json:"height"`
	OriginalFormat string  `json:"original_format"`
	EncodingFormat string  `json:"encoding_format"`
	Latitude       float64 `json:"latitude,omitempty"`
	Longitude      float64 `json:"longitude,omitempty"`
}

func MakeMetadata

func MakeMetadata(reader io.Reader, path string, ext string, format Format, encodingFormat Format, width int, height int, version string) (PhotoMetadata, error)

MakeMetadata reads any available meta/exif data from a photo

type PublishOpts

type PublishOpts struct {
	VerifyExists bool
	PubValidTime time.Duration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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