bclientapi

package
v0.0.0-...-bd9ca74 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTransaction = errors.New("error processing transaction")
	ErrTimeout     = errors.New("timeout processing transaction")
)
View Source
var (
	ErrNotFound         = errors.New("Item Not Found in Bendo")
	ErrNotAuthorized    = errors.New("Access Denied")
	ErrUnexpectedResp   = errors.New("Unexpected Response Code")
	ErrReadFailed       = errors.New("Read Failed")
	ErrChecksumMismatch = errors.New("Checksum mismatch")
	ErrServerError      = errors.New("Server Error")
)

Exported errors

Functions

This section is empty.

Types

type Connection

type Connection struct {
	// The bendo server this connection is to
	HostURL string

	// The chunk size to use for uploading files.
	// If 0, defaults to 10485760 bytes = 10 MB.
	ChunkSize int

	// An API key to use when interacting with the server.
	Token string
	// contains filtered or unexported fields
}

A Connection represents a connection with a Bendo Service. It can be shared between multiple goroutines.

func (*Connection) CreateTransaction

func (c *Connection) CreateTransaction(item string, cmdlist []byte) (string, error)

func (*Connection) Download

func (c *Connection) Download(w io.Writer, item string, filename string) error

Download copies the given (item, filename) pair from bendo to the given io.Writer.

func (*Connection) ItemInfo

func (c *Connection) ItemInfo(item string) (*jason.Object, error)

func (*Connection) TransactionStatus

func (c *Connection) TransactionStatus(txid string) (TransactionInfo, error)

TransactionStatus returns info on the given transaction ID. If the transaction is being processed, it does not wait for the transaction to finish. The status is an integer as given by transaction.TransactionStatus.

func (*Connection) Upload

func (c *Connection) Upload(uploadname string, r io.ReadSeeker, info FileInfo) error

Upload copies r to the bendo server, storing it under the name uploadname. r must support seeking since that is used to determine the length of the content and if the md5 sum is not set in info, this function will first read r to compute it and then seek back to the beginning to then copy r to the server. Upload() will resume a partial upload if only part of r is on the server.

func (*Connection) WaitTransaction

func (c *Connection) WaitTransaction(txid string) error

WaitTransaction waits for the given transaction to finish. It will return an error if the transaction had an error. It will poll the server for up to 12 hours, and then return a timeout error.

type FileInfo

type FileInfo struct {
	Size     int64  // the size of this file
	MD5      []byte // the md5 hash for the entire file being uploaded
	Mimetype string // the mimetype of this file
}

type TransactionInfo

type TransactionInfo struct {
	Status transaction.Status
	Errors []string
}

Jump to

Keyboard shortcuts

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