upload

package
v0.0.0-...-011315e Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AcceptsImgExt  图片类型
	AcceptsImgExt = []string{"jpg", "png", "jpeg", "webp", "gif"}
	// AcceptsVideoExt 视频类型
	AcceptsVideoExt = []string{"mov", "mp4", "avi"}
	// AcceptsAudioExt 音频类型
	AcceptsAudioExt = []string{"mp3", "aac", "wav", "ogg"}
	//AcceptsOtherFileExt 文件类型
	AcceptsOtherFileExt = []string{"pdf", "zip", "rar", "gz", "txt"}
)
View Source
var DefaultGetFile = defaultGetFile

DefaultGetFile 默认从http请求读取文件流到方法

View Source
var DefaultUpload = defaultUpload

DefaultUpload 默认上传拷贝文件

Functions

func GetDir

func GetDir(path string, foderName string) (dir string, err error)

GetDir 创建文件夹

func RandStringBytes

func RandStringBytes(n int) string

RandStringBytes 随机字符串

Types

type Size

type Size interface {
	Size() int64
}

Size 获取文件大小的接口

type Stat

type Stat interface {
	Stat() (os.FileInfo, error)
}

Stat 获取文件信息的接口

type Uploader

type Uploader struct {
	BaseDir      string
	UploadMethod uploadMethod
	GetFile      getFile
	MaxSize      int
}

Uploader Uploader

func NewDefaultUploader

func NewDefaultUploader() *Uploader

NewDefaultUploader 默认上传

func (*Uploader) Custom

func (u *Uploader) Custom(httpContext *http.Request, acceptsExt []string, folder string) (url string, err error)

Custom 自定义上传类型和目录

func (*Uploader) Default

func (u *Uploader) Default(httpContext *http.Request) (path string, err error)

Default 默认上传类型和文件夹

func (*Uploader) OnlyAcceptsExt

func (u *Uploader) OnlyAcceptsExt(httpContext *http.Request, acceptsExt []string, folder string) (url string, err error)

OnlyAcceptsExt 限制类型 比如:仅图片

Jump to

Keyboard shortcuts

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