upload

package
v2.1.8 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AllowImageExts = []string{".jpeg", ".jpg", ".png", ".bmp", ".gif"}
	AllowAnyExts   = []string{"*"}
)

Functions

func CheckFileExt

func CheckFileExt(fileName string, exts *[]string) bool

判断一个文件的拓展名是否在切片内

func RandFileName

func RandFileName(name string) string

使用md5随机生成一个文件名

func ReadyDir

func ReadyDir(src string) error

就绪一个文件夹

Types

type File

type File struct {
	Name string
	Size int64
	Save string
}

type FileAttribute

type FileAttribute struct {
	Key     string
	Exts    []string
	DirPath string
	MaxByte int64
}

func (FileAttribute) CheckFile added in v2.1.5

func (a FileAttribute) CheckFile(fileHeader *multipart.FileHeader) (err error)

type FileUpload added in v2.1.0

type FileUpload interface {
	Upload(c *gin.Context, attribute FileAttribute) (File, error)
	Remove(path string) error
	URL(domain, filePath string) (*url.URL, error)
}

type Local added in v2.1.0

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

func NewLocal added in v2.1.0

func NewLocal(baseDir string) *Local

func (*Local) Remove added in v2.1.0

func (l *Local) Remove(filename string) error

func (*Local) URL added in v2.1.5

func (l *Local) URL(domain, filePath string) (*url.URL, error)

func (*Local) Upload added in v2.1.0

func (l *Local) Upload(c *gin.Context, attr FileAttribute) (f File, e error)

r.StaticFS("/upload/resources", http.Dir(upload.GetresourceFullPath()))

type Oss added in v2.1.0

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

func NewOss added in v2.1.0

func NewOss(endpoint, accessKeyID, accessKeySecret, bucketName string) (*Oss, error)

func (*Oss) Remove added in v2.1.0

func (oss *Oss) Remove(filename string) error

func (*Oss) URL added in v2.1.5

func (oss *Oss) URL(domain, filePath string) (*url.URL, error)

func (*Oss) Upload added in v2.1.0

func (oss *Oss) Upload(c *gin.Context, attr FileAttribute) (f File, e error)

Jump to

Keyboard shortcuts

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