upload

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2021 License: MIT Imports: 12 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 AliOssConf

type AliOssConf struct {
	Endpoint        string `json:"endpoint"`
	AccessKeyID     string `json:"access_key_id"`
	AccessKeySecret string `json:"Access_key_secret"`
	URL             string `json:"url"`
	Bucket          string `json:"bucket"`
}

AliOssConf AliOssConf

type Uploader

type Uploader struct {
	BaseDir      string
	UploadMethod uploadMethod
	GetFile      getFile
}

Uploader Uploader

func NewAliOssUploader

func NewAliOssUploader(ali AliOssConf) *Uploader

NewAliOssUploader 阿里云上传

func NewEchoUploader

func NewEchoUploader() *Uploader

NewEchoUploader EchoUploader

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