storage

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFileNotFound = errors.New("file not found")
)

Functions

func Apply

func Apply(opts ...Option) option

Types

type Attrs

type Attrs struct {
	ContentType  string
	StorageClass string
}

type Client

type Client struct {
	StorageStrategy Strategy
}

func NewStorageClient

func NewStorageClient(ctx context.Context, storageStrategy Strategy) (*Client, error)

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, uri string, options ...Option) error

Delete enables to delete file.

func (*Client) Download

func (c *Client) Download(ctx context.Context, uri string, options ...Option) ([]byte, error)

Download enables to download file content in slice of byte.

func (*Client) DownloadTo

func (c *Client) DownloadTo(ctx context.Context, source string, destination string, options ...Option) error

DownloadTo enables to download file content in local file.

func (*Client) Exist

func (c *Client) Exist(ctx context.Context, uri string) (bool, error)

Exist checks if file exist.

func (*Client) GetAttrs

func (c *Client) GetAttrs(ctx context.Context, uri string) (Attrs, error)

GetAttrs returns file attributes.

func (*Client) StreamAt added in v0.3.0

func (c *Client) StreamAt(key string, off int64, n int64) (io.ReadCloser, int64, error)

StreamAt streams storage files

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, uri string, data []byte, options ...Option) error

Upload enables to upload file content in to remote file.

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, uri string, data io.ReadCloser, options ...Option) error

UploadFile enables to upload file in to remote file.

type ExcludeFunc

type ExcludeFunc func(objectName string) bool

type Option

type Option func(o *option)

func Concurrency

func Concurrency(c int) Option

func Exclude

func Exclude(ex ExcludeFunc) Option

func Length

func Length(l int64) Option

func MaxTries

func MaxTries(n int) Option

func Offset

func Offset(off int64) Option

func OnErrorRetryDelay

func OnErrorRetryDelay(d time.Duration) Option

func StorageClass

func StorageClass(cl string) Option

type Strategy

type Strategy interface {
	Download(ctx context.Context, uri string, options ...Option) ([]byte, error)
	DownloadToFile(ctx context.Context, source string, destination string, options ...Option) error
	Upload(ctx context.Context, uri string, data []byte, options ...Option) error
	UploadFile(ctx context.Context, uri string, data io.ReadCloser, options ...Option) error
	Delete(ctx context.Context, uri string, options ...Option) error
	Exist(ctx context.Context, uri string) (bool, error)
	GetAttrs(ctx context.Context, uri string) (Attrs, error)
	StreamAt(key string, off int64, n int64) (io.ReadCloser, int64, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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