storage

package
v0.0.0-...-bdc8d50 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSuchKey = errors.New("NoSuchKey: The specified key does not exist.")

ErrNoSuchKey .

Functions

func ErrorValidator

func ErrorValidator(vs ...Validator) error

ErrorValidator .

func Init

func Init(c Client, err error) error

Init .

Types

type BucketName

type BucketName string

BucketName bucket name

func (BucketName) Error

func (n BucketName) Error() error

Error .

type Client

type Client interface {
	// PutObject 上传单个对象
	PutObject(input ObjectInput, opts ...func(o *PutOptions)) error
	// PutFolder 上传本地文件夹,存储路径为 'prefix/root/xxx'
	PutFolder(bucket string, prefix string, root string, opts ...func(o *PutOptions)) error

	// GetObject 根据对象路径,获取单个对象
	GetObject(bucket string, key string, opts ...func(o *GetOptions)) (*ObjectOutputHook, error)
	// GetObjectsWithIterator 根据对象前缀,获取多个对象
	GetObjectsWithIterator(bucket string, prefix string, iterator func(keys []*string) error, opts ...func(o *ListOptions)) error

	// DelObject 删除单个对象
	DelObject(bucket string, key string, opts ...func(o *DelOptions)) error
	// DelObjectsWithPrefix 根据对象前缀,删除多个对象
	DelObjectsWithPrefix(bucket string, prefix string, opts ...func(o *DelOptions)) error

	// Copy 对象拷贝
	Copy(src Position, dst Position, opts ...func(o *CopyOptions)) error

	// IsExist 查询对象是否存在
	IsExist(bucket string, key string, opts ...func(o *GetOptions)) (bool, error)

	// Presign 获取对象 HTTP 访问路径
	Presign(bucket string, key string, opts ...func(o *PresignOptions)) (string, error)

	// Downloads 根据前缀,批量下载对象至本地存储,本地存储路径为 'root/prefix/xxx'
	Downloads(bucket string, prefix string, root string, opts ...func(o *ListOptions)) error
}

Client .

var C Client

C default Client

type CopyOptions

type CopyOptions struct {
	Context context.Context
	// increases the number of callers skipped by caller annotation
	CallerSkip int
}

CopyOptions .

func NewCopyOptions

func NewCopyOptions(opts ...func(o *CopyOptions)) *CopyOptions

NewCopyOptions .

type DelOptions

type DelOptions struct {
	Context context.Context
	// object version id
	VersionID string
	// increases the number of callers skipped by caller annotation
	CallerSkip int
}

DelOptions .

func NewDelOptions

func NewDelOptions(opts ...func(o *DelOptions)) *DelOptions

NewDelOptions .

type GetOptions

type GetOptions struct {
	Context context.Context
	// object version
	VersionID string
	// increases the number of callers skipped by caller annotation
	CallerSkip int
}

GetOptions .

func NewGetOptions

func NewGetOptions(opts ...func(o *GetOptions)) *GetOptions

NewGetOptions .

type KeyName

type KeyName string

KeyName key name

func (KeyName) Error

func (n KeyName) Error() error

Error .

type KeyPrefixName

type KeyPrefixName string

KeyPrefixName prefix of key

func (KeyPrefixName) Error

func (n KeyPrefixName) Error() error

Error .

type ListOptions

type ListOptions struct {
	Context context.Context
	MaxKeys int
	// ignore '/' delimiter
	Recursive bool
	// increases the number of callers skipped by caller annotation
	CallerSkip int
}

ListOptions .

func NewListOptions

func NewListOptions(opts ...func(o *ListOptions)) *ListOptions

NewListOptions .

type ObjectInput

type ObjectInput interface {
	Bucket() string
	Key() string
	ContentType() string
	Close() error
	Error() error
	Body() io.ReadSeeker
}

ObjectInput .

func InputBoolean

func InputBoolean(bucket string, key string, v bool) ObjectInput

InputBoolean .

func InputFile

func InputFile(bucket string, key string, file string) ObjectInput

InputFile .

func InputMarshalJson

func InputMarshalJson(bucket string, key string, vPointer interface{}) ObjectInput

InputMarshalJson .

func InputMarshalProto

func InputMarshalProto(bucket string, key string, v proto.Message) ObjectInput

InputMarshalProto .

func InputNumber

func InputNumber(bucket string, key string, v interface{}) ObjectInput

InputNumber .

func InputReadSeeker

func InputReadSeeker(bucket string, key string, body io.ReadSeeker) ObjectInput

InputReadSeeker .

func InputString

func InputString(bucket string, key string, v string) ObjectInput

InputString .

type ObjectOutput

type ObjectOutput interface {
	Bucket() string
	Key() string
	ContentType() content.Type
	Decode(vPointer interface{}) error
	Body() io.ReadCloser
	Close() error
}

ObjectOutput .

func OutputReadCloser

func OutputReadCloser(bucket string, key string, contenttype string, body io.ReadCloser) ObjectOutput

OutputReadCloser .

type ObjectOutputHook

type ObjectOutputHook struct {
	// Fetch get object with io.ReadCloser
	Fetch func(hook func(output ObjectOutput) error) error
	// Write write object to io.WriterAt
	Write func(w io.WriterAt) error
}

ObjectOutputHook .

type Options

type Options struct {
	// Context context
	Context context.Context
	// Timeout 连接超时时间
	Timeout time.Duration
	// Region region
	Region string
	// SSL use ssl
	UseSSL bool
}

Options .

func NewOptions

func NewOptions(opts ...func(o *Options)) *Options

NewOptions .

type Position

type Position interface {
	Bucket() string
	Key() string
	IsPrefix() bool
}

Position .

func PositionRemote

func PositionRemote(bucket, path string) Position

PositionRemote .

type PresignOptions

type PresignOptions struct {
	Context context.Context
	// object version id
	VersionID string
	// expires time (s)
	Expires time.Duration
	// increases the number of callers skipped by caller annotation
	CallerSkip int
}

PresignOptions .

func NewPresignOptions

func NewPresignOptions(opts ...func(o *PresignOptions)) *PresignOptions

NewPresignOptions .

type PutOptions

type PutOptions struct {
	Context context.Context
	// increases the number of callers skipped by caller annotation
	CallerSkip int
}

PutOptions .

func NewPutOptions

func NewPutOptions(opts ...func(o *PutOptions)) *PutOptions

NewPutOptions .

type Validator

type Validator interface {
	Error() error
}

Validator .

type ValidatorFunc

type ValidatorFunc func() error

ValidatorFunc error func

func (ValidatorFunc) Error

func (f ValidatorFunc) Error() error

Error .

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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