storage

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: MIT Imports: 15 Imported by: 4

README

storage

infra.Go storage module.

Documentation

Index

Constants

View Source
const (
	NAME = "STORE"
)

Variables

This section is empty.

Functions

func Browse

func Browse(code string, query Map, expires ...time.Duration) (string, error)

func Download

func Download(code string) (string, error)

func Preview

func Preview(code string, width, height int64) (string, error)

func PreviewConfig

func PreviewConfig() string

func Remove

func Remove(code string) error

func SaltConfig

func SaltConfig() string

func StatFile

func StatFile(file string) (Map, error)

func Thumbnail

func Thumbnail(code string, width, height, pos int64) (string, error)

func ThumbnailConfig

func ThumbnailConfig() string

func Upload

func Upload(from Any, metadatas ...Map) (File, Files, error)

func UploadTo

func UploadTo(base string, from Any, metadatas ...Map) (File, Files, error)

Types

type Config

type Config struct {
	Driver  string
	Weight  int
	Proxy   bool
	Remote  bool
	Setting Map
}

type Configs

type Configs map[string]Config

type Connect

type Connect interface {
	Open() error
	Health() Health
	Close() error

	Upload(path string, metadata Map) (File, Files, error)
	Download(file File) (string, error)
	Remove(file File) error
	Browse(file File, query Map, expires time.Duration) (string, error)
}

Connect

type Driver

type Driver interface {
	Connect(*Instance) (Connect, error)
}

Driver

type File

type File interface {
	Base() string
	Hash() string
	Type() string
	Size() int64

	File() string
	Name() string
	Code() string

	Proxy() bool
	Remote() bool
}

func Decode

func Decode(code string) (File, error)

func UploadFile

func UploadFile(path Any, metadatas ...Map) (File, error)

func UploadFileTo

func UploadFileTo(base string, path Any, metadatas ...Map) (File, error)

type Files

type Files []File

func UploadPath

func UploadPath(path Any, metadatas ...Map) (Files, error)

func UploadPathTo

func UploadPathTo(base string, path Any, metadatas ...Map) (Files, error)

type Health

type Health struct {
	Workload int64
}

Health

type Info

type Info struct {
	Type string
	File string
}

type Instance

type Instance struct {
	Name    string
	Config  Config
	Setting Map
	// contains filtered or unexported fields
}

func (*Instance) Download

func (this *Instance) Download(file File) (string, error)

统一返回本地缓存目录

func (*Instance) File

func (this *Instance) File(hash string, file string, size int64) File

func (*Instance) Hash

func (this *Instance) Hash(file string) string

type Module

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

func (*Module) Browse

func (this *Module) Browse(code string, query Map, expires ...time.Duration) (string, error)

func (*Module) Config

func (this *Module) Config(name string, config Config)

func (*Module) Configs

func (this *Module) Configs(config Configs)

func (*Module) Configure

func (this *Module) Configure(global Map)

func (*Module) Connect

func (this *Module) Connect()

func (*Module) Download

func (this *Module) Download(code string) (string, error)

func (*Module) Driver

func (module *Module) Driver(name string, driver Driver)

func (*Module) Initialize

func (this *Module) Initialize()

func (*Module) Launch

func (this *Module) Launch()

func (*Module) Preview

func (this *Module) Preview(code string, width, height, position int64) (string, error)

Preview 生成缩略图

func (*Module) Previewer

func (this *Module) Previewer(name string, config Previewer)

func (*Module) Register

func (this *Module) Register(name string, value Any)

func (*Module) Remove

func (this *Module) Remove(code string) error

func (*Module) Terminate

func (this *Module) Terminate()

func (*Module) Thumbnail

func (this *Module) Thumbnail(code string, width, height, position int64) (string, error)

Thumbnail 生成缩略图

func (*Module) Thumbnailer

func (this *Module) Thumbnailer(name string, config Thumbnailer)

func (*Module) Upload

func (this *Module) Upload(path string, metadata Map) (File, Files, error)

func (*Module) UploadTo

func (this *Module) UploadTo(base string, path string, metadata Map) (File, Files, error)

type Previewer

type Previewer struct {
	// Name 名称
	Name string
	// Text 说明
	Text string
	// Alias 别名
	Alias []string
	// Preview 预览动图
	Action PreviewerFunc
}

type PreviewerFunc

type PreviewerFunc func(File, int64, int64, int64) (string, error)

type ThumbnailFunc

type ThumbnailFunc func(File, int64, int64, int64) (string, error)

type Thumbnailer

type Thumbnailer struct {
	// Name 名称
	Name string
	// Text 说明
	Text string
	// Alias 别名
	Alias []string
	// Thumbnail 缩图
	Action ThumbnailFunc
}

Jump to

Keyboard shortcuts

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