storages

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OSSBucketInterface

type OSSBucketInterface interface {
	PutObject(objectKey string, reader io.Reader, options ...oss.Option) error
	GetObject(objectKey string, options ...oss.Option) (io.ReadCloser, error)
	DeleteObject(objectKey string, options ...oss.Option) error
}

OSSBucketInterface 是为了脱离bucket带来的影响. 如mock时, 如果使用 oss.Client 则无法mock(Client is struct)

type OSSOptions

type OSSOptions struct {
	Endpoint        string `yaml:"endpoint" mapstructure:"endpoint"`
	AccessKeyID     string `yaml:"access_key_id" mapstructure:"access_key_id"`
	AccessKeySecret string `yaml:"access_key_secret" mapstructure:"access_key_secret"`
	Bucket          string `yaml:"bucket" mapstructure:"bucket"`
	UseHTTPS        bool   `yaml:"use_https" mapstructure:"use_https"`
	Domain          string `yaml:"domain" mapstructure:"domain"`
}

OSSOptions is Oss 存储所需的配置项

type OSSStorage

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

OSSStorage oss 客户端

func NewOssClient

func NewOssClient(opts *OSSOptions) (*OSSStorage, error)

NewOssClient is 创建oss客户端

func (*OSSStorage) Del

func (s *OSSStorage) Del(ctx context.Context, fileID string) error

func (*OSSStorage) Fetch

func (s *OSSStorage) Fetch(ctx context.Context, fileID string, writer io.Writer) error

Writer 可以直接将数据写入传入的结构体. 如传入 bytes.Buffer, 数据直接可写入buffer.

func (*OSSStorage) Name

func (s *OSSStorage) Name() string

func (*OSSStorage) Save

func (s *OSSStorage) Save(ctx context.Context, fileID string, reader io.Reader) error

func (*OSSStorage) URL

func (s *OSSStorage) URL(ctx context.Context, fileID string) (*url.URL, error)

Jump to

Keyboard shortcuts

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