oss

package module
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ShanghaiLoc, _ = time.LoadLocation("Asia/Shanghai")

Functions

This section is empty.

Types

type Config

type Config struct {
	NameSpace   string
	FileName    string
	FileType    string
	GzCompress  bool // use gz compress
	WriteThread int
	ReadThread  int
}

type FileStore

type FileStore struct {
	// contains filtered or unexported fields
}

func NewFileStore

func NewFileStore(baseDir string) *FileStore

func (*FileStore) Del

func (f *FileStore) Del(keys []string) error

func (*FileStore) Get

func (f *FileStore) Get(key string) (io.ReadCloser, error)

func (*FileStore) IsNotExistErr

func (f *FileStore) IsNotExistErr(err error) bool

func (*FileStore) PresignURL added in v0.5.0

func (f *FileStore) PresignURL(key, method string, expired time.Duration) (*url.URL, error)

func (*FileStore) Set

func (f *FileStore) Set(key string, reader io.Reader) error

type KV

type KV struct {
	Key string
	Val []byte
}

type OKV

type OKV struct {
	// contains filtered or unexported fields
}

func NewOKV

func NewOKV(store Store, conf Config) *OKV

func (*OKV) Del

func (o *OKV) Del(keys []string) error

func (*OKV) Get

func (o *OKV) Get(keys []string) (map[string][]byte, error)

func (*OKV) GetBatch

func (o *OKV) GetBatch(keys []string) ([]*KV, error)

func (*OKV) GetOne

func (o *OKV) GetOne(key string) ([]byte, error)

func (*OKV) Path

func (o *OKV) Path(key string) string

Path returns the object path of key, be likes namespace/key[/filename][.ext][.gz]

func (*OKV) PresignURL added in v0.5.1

func (o *OKV) PresignURL(key string, method string, expired time.Duration) (*url.URL, error)

PresignURL 上传(put)/下载(get)

func (*OKV) Put

func (o *OKV) Put(data map[string][]byte) error

func (*OKV) PutBatch

func (o *OKV) PutBatch(kvList []*KV) error

func (*OKV) PutOne

func (o *OKV) PutOne(key string, val []byte) error

type OSS

type OSS struct {
	// contains filtered or unexported fields
}

func NewOSS

func NewOSS(store Store, pathPrefix string) *OSS

func (*OSS) Delete

func (c *OSS) Delete(filePath []string) error

Delete file form COS

func (*OSS) Get

func (c *OSS) Get(filePath string) (io.ReadCloser, error)

func (*OSS) GetByte

func (c *OSS) GetByte(filePath string) ([]byte, error)

func (*OSS) PresignURL added in v0.5.2

func (c *OSS) PresignURL(path string, method string, expired time.Duration) (*url.URL, error)

PresignURL 上传(put)/下载(get)

func (*OSS) UnZip

func (c *OSS) UnZip(filePath string, rename func(file *zip.File) string) (map[string][]byte, error)

func (*OSS) Upload

func (c *OSS) Upload(filename string, reader io.Reader) (string, error)

Upload file to COS

type Store

type Store interface {
	Set(key string, reader io.Reader) error
	Get(key string) (io.ReadCloser, error)
	Del(key []string) error
	IsNotExistErr(error) bool
	PresignURL(key, method string, expired time.Duration) (*url.URL, error)
}

Jump to

Keyboard shortcuts

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