storage

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2025 License: MIT Imports: 19 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, opts ...BrowseOption) (string, error)

func DecodeImageConfig added in v0.1.0

func DecodeImageConfig(r io.Reader) (image.Config, error)

Decode reads an image from r.

func Download

func Download(code string, opts ...DownloadOption) (string, error)

func ImageConfig added in v0.1.0

func ImageConfig(filename string) (image.Config, error)

Open loads an image from file

func Preview

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

func PreviewConfig

func PreviewConfig() string

func Remove

func Remove(code string, opts ...RemoveOption) 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

Types

type BrowseOption added in v0.1.0

type BrowseOption struct {
	Headers Map
	Params  Map
}

type Config

type Config struct {
	Driver  string
	Weight  int
	Prefix  string
	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(string, UploadOption) (*File, error)
	Fetch(*File, FetchOption) (Stream, error)
	Download(*File, DownloadOption) (string, error)

	Remove(*File, RemoveOption) error
	Browse(*File, BrowseOption) (string, error)
}

Connect

type DownloadOption added in v0.1.0

type DownloadOption struct {
	Target string
}

type Driver

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

Driver

type FetchOption added in v0.1.0

type FetchOption struct {
	//range支持
	Start int64
	End   int64
}

type File

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

func Decode

func Decode(code string) (*File, error)

func Upload

func Upload(from Any, opts ...UploadOption) (*File, error)

func UploadTo

func UploadTo(base string, from Any, opts ...UploadOption) (*File, error)

func (*File) Base

func (sf *File) Base() string

func (*File) Code

func (sf *File) Code() string

func (*File) File

func (sf *File) File() string

func (*File) Key added in v0.1.0

func (sf *File) Key() string

func (*File) Name

func (sf *File) Name() string

func (*File) Prefix added in v0.1.0

func (sf *File) Prefix() string

func (*File) Proxy

func (sf *File) Proxy() bool

func (*File) Remote

func (sf *File) Remote() bool

func (*File) Size

func (sf *File) Size() int64

func (*File) Type

func (sf *File) Type() string

type Files

type Files []File
	Code() string
	Proxy() bool
	Remote() bool
}

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) File

func (this *Instance) File(prefix, key, tttt string, size int64) *File

type Module

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

func (*Module) Browse

func (this *Module) Browse(code string, opts ...BrowseOption) (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, opts ...DownloadOption) (string, error)

func (*Module) Driver

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

func (*Module) Fetch added in v0.1.0

func (this *Module) Fetch(code string, opts ...FetchOption) (Stream, error)

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, opts ...RemoveOption) 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(orginal string, opts ...UploadOption) (*File, error)

func (*Module) UploadTo

func (this *Module) UploadTo(base string, orginal string, opts ...UploadOption) (*File, 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 Range added in v0.1.0

type Range struct {
}

type RemoveOption added in v0.1.0

type RemoveOption struct {
}

type Stream added in v0.1.0

type Stream interface {
	io.Reader
	io.Seeker
	io.Closer
	io.ReaderAt
}

func Fetch added in v0.1.0

func Fetch(code string, opts ...FetchOption) (Stream, 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
}

type UploadOption added in v0.1.0

type UploadOption struct {
	Key    string
	Prefix string

	Mimetype string
	Metadata Map
	Tags     Map
	Expires  time.Time
}

Jump to

Keyboard shortcuts

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