driver

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2019 License: AGPL-3.0 Imports: 11 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrExistsFile 文件不存在
	ErrExistsFile = table.ErrExistsFile
)

Functions

func All

func All(engine string) map[string]Constructor

All 存储引擎集合

func BatchUpload

func BatchUpload(
	ctx echo.Context,
	fieldName string,
	dstNamer func(*uploadClient.Result) (dst string, err error),
	storer Storer,
	callback func(*uploadClient.Result, multipart.File) error,
) (results uploadClient.Results, err error)

BatchUpload 批量上传

func Register

func Register(engine string, constructor Constructor)

Register 存储引擎注册

Types

type Constructor

type Constructor func(ctx context.Context, typ string) Storer

Constructor 存储引擎构造函数

var DefaultConstructor Constructor

DefaultConstructor 默认构造器

func Get

func Get(engine string) Constructor

Get 获取存储引擎构造器

type Sizer

type Sizer interface {
	Size() int64
}

Sizer 尺寸接口

type Storer

type Storer interface {
	// 引擎名
	Name() string

	// FileDir 文件夹物理路径
	FileDir(subpath string) string

	// URLDir 文件夹网址路径
	URLDir(subpath string) string

	// Put 保存文件
	Put(dst string, src io.Reader, size int64) (savePath string, viewURL string, err error)

	// Get 获取文件
	Get(file string) (io.ReadCloser, error)

	// Exists 文件是否存在
	Exists(file string) (bool, error)

	// FileInfo 文件信息
	FileInfo(file string) (os.FileInfo, error)

	// SendFile 输出文件到浏览器
	SendFile(ctx echo.Context, file string) error

	// Delete 删除文件
	Delete(file string) error

	// DeleteDir 删除目录
	DeleteDir(dir string) error

	// Move 移动文件
	Move(src, dst string) error

	// PublicURL 文件物理路径转网址
	PublicURL(dst string) string

	// URLToFile 网址转文件物理路径
	URLToFile(viewURL string) string

	// FixURL 修正网址
	FixURL(content string, embedded ...bool) string

	// FixURLWithParams 修正网址并增加网址参数
	FixURLWithParams(content string, values url.Values, embedded ...bool) string

	// Close 关闭连接
	Close() error
}

Storer 文件存储引擎接口

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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