upload

package
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

* * @Author: TheLife * @Date: 2020-2-25 9:00 下午

* * @Author: TheLife * @Date: 2020-2-25 9:00 下午

* * @Author: TheLife * @Date: 2020-2-25 9:00 下午

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 {
	Error error
	Url   string
	Save  string
}

type FileAttribute

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

type FileUpload added in v2.1.0

type FileUpload interface {
	Upload(c *gin.Context, attribute FileAttribute) File
	Remove(path string) 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, domain string) *Local

func (Local) Remove added in v2.1.0

func (l Local) Remove(filename string) error

func (Local) Upload added in v2.1.0

func (l Local) Upload(c *gin.Context, attribute FileAttribute) File

r.StaticFS("/upload/images", http.Dir(upload.GetImageFullPath()))

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, haveDomain string) (*Oss, error)

func (*Oss) Remove added in v2.1.0

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

func (*Oss) Upload added in v2.1.0

func (oss *Oss) Upload(c *gin.Context, attribute FileAttribute) File

Jump to

Keyboard shortcuts

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