storage

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: MIT Imports: 5 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FileNotFoundErr     = errors.New("file not found")
	FileNoPermissionErr = errors.New("permission denied")
)

Functions

func NormalizeKey

func NormalizeKey(key string) string

func OpenAsReadOnly

func OpenAsReadOnly(key string) (*os.File, os.FileInfo, error)

func Register

func Register(name DiskName, disk Storage)

Types

type DiskName

type DiskName string
const (
	Local DiskName = "local" // 本地
	KoDo  DiskName = "kodo"  // 七牛云
	Oss   DiskName = "oss"   // 阿里云
)

type Storage

type Storage interface {
	Put(key string, r io.Reader, dataLength int64) error
	PutFile(key string, localFile string) error
	Get(key string) (io.ReadCloser, error)
	Rename(srcKey string, destKey string) error
	Copy(srcKey string, destKey string) error
	Exists(key string) (bool, error)
	Size(key string) (int64, error)
	Delete(key string) error
	Url(key string) string
}

func Disk

func Disk(name DiskName) (Storage, error)

Jump to

Keyboard shortcuts

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