provider

package
v0.0.0-...-75939a1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VolumeTypeLocal = "local"
	VolumeTypeS3    = "s3"
	VolumeTypeOss   = "oss"
	VolumeTypeCos   = "cos"
)
View Source
const (
	NoSort   = FileSort("")
	NameSort = FileSort("name")
	ExtSort  = FileSort("ext")
	TimeSort = FileSort("updated_at")
	SizeSort = FileSort("size")
)

Variables

This section is empty.

Functions

func NewLocalProvider

func NewLocalProvider(id string, data []byte) (*localProvider, error)

Types

type FileInfo

type FileInfo struct {
	IsDir     bool   `json:"is_dir"`
	Path      string `json:"path"`
	Name      string `json:"name"`
	Size      int64  `json:"size"`
	Ext       string `json:"ext"`
	UpdatedAt int64  `json:"updated_at"`
}

type FileSort

type FileSort string

type ListOption

type ListOption struct {
	Path     string
	HideFile bool
	Type     uint32
	Sort     FileSort
	SortDesc bool
}

type VolumeProvider

type VolumeProvider interface {
	// 供应商类型
	GetProviderType() string
	GetFileUrl(ctx context.Context, path string) (string, error)
	// 大文件上传
	HttpBigUpload(w http.ResponseWriter, r *http.Request) error
	// 上传文件
	Upload(ctx context.Context, fileName string, data []byte) error
	// 删除文件
	Delete(ctx context.Context, fileName string) error
	// 文件是否存在
	Exists(ctx context.Context, path string) bool
	// 打开文件
	Open(ctx context.Context, name string) (io.ReadWriteCloser, error)
	// 创建文件
	Create(ctx context.Context, name string) (io.ReadWriteCloser, error)
	// 创建文件
	CreateDir(ctx context.Context, name string) error
	// 遍历
	Walk(path string, fn filepath.WalkFunc) error
	// 文件列表
	List(ctx context.Context, req ListOption) ([]FileInfo, error)
	// 重命名
	Rename(context.Context, string, string) error
}

func Parse

func Parse(t string, id string, config []byte) (VolumeProvider, error)

Jump to

Keyboard shortcuts

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