storage

package
v0.0.0-...-33c5ed1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidKey = errors.New("未实现的driver")
View Source
var ErrNoService = errors.New("未注册服务")

Functions

func RegisterFunc

func RegisterFunc(driver string, f NewStorageFunc)

Types

type Config

type Config struct {
	Thumb          ThumbConfig   `json:"thumb" yaml:"thumb"`                     // 缩略图配置
	DefaultStorage ConfigStorage `json:"default_storage" yaml:"default_storage"` // 默认存储引擎

}

配置

type ConfigStorage

type ConfigStorage struct {
	Key             string `json:"key" yaml:"key"`                             // 注册时用的key
	Driver          string `json:"driver" yaml:"driver"`                       // 类型
	AccessKeyID     string `json:"access_key_id" yaml:"access_key_id"`         //
	AccessKeySecret string `json:"access_key_secret" yaml:"access_key_secret"` //
	Endpoint        string `json:"endpoint" yaml:"endpoint"`                   // endpoint
	Bucket          string `json:"bucket" yaml:"bucket"`                       // bucket
	WithAcl         bool   `json:"with_acl" yaml:"with_acl"`
	Expiration      int    `json:"expiration" yaml:"expiration"` // 过期时间 单位:秒
}

type Factory

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

type IStorage

type IStorage interface {
	// 推送文件
	PushFile(objName string, reader io.Reader) (link string, err error)
	// 添加目录
	CreateDir(dirName string) error
	// 删除文件
	DeleteFile(objName string) error
	// 获取文件链接
	GetUrl(objName string) (link string, err error)
	GetUrls(objNames []string) (links []string, err error)
	// 获取缩略图地址
	GetThumbUrl(objName string) (link string, err error)
	GetThumbUrls(objNames []string) (links []string, err error)
	// 获取文件
	GetFile(objName string) (io.Reader, error)
	GetFileTo(objName string, w io.Writer) error
	// 递归扫描
	ScanDst(dst string) ([]map[string]string, error)
}

存储介质

type NewStorageFunc

type NewStorageFunc func(conf ConfigStorage) (IStorage, error)

func FactoryGet

func FactoryGet(driver string) (NewStorageFunc, error)

func FactoryGetDefault

func FactoryGetDefault() NewStorageFunc

type Service

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

func NewService

func NewService(conf Config) (*Service, error)

func (*Service) CreateDir

func (s *Service) CreateDir(objName string) error

添加文件夹

func (*Service) GetStorageTyp

func (s *Service) GetStorageTyp() string

func (*Service) UploadFile

func (s *Service) UploadFile(objName string, reader io.Reader) (string, error)

上传文件

type ThumbConfig

type ThumbConfig struct {
	Enable bool   `json:"enable" yaml:"enable"`
	Width  int    `json:"width" yaml:"width"`
	Height int    `json:"height" yaml:"height"`
	FFMpeg string `json:"ffmpeg" yaml:"ffmpeg"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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