storage

package
v0.0.0-...-d3a193e Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func GetFileMd5

func GetFileMd5(f multipart.File) string

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 = "qiniu" // 七牛云
	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