Documentation ¶
Index ¶
- Variables
- func BatchUpload(ctx echo.Context, fieldName string, ...) ([]string, error)
- func CheckerAll() map[string]Checker
- func CheckerRegister(typ string, checker Checker)
- func CleanTempFile(prefix string, deleter func(folderPath string) error) error
- func ResponserAll() map[string]Responser
- func ResponserRegister(field string, responser Responser)
- func SubdirAll() map[string]bool
- func SubdirIsAllowed(subdir string) bool
- func SubdirRegister(subdir string, allow bool)
- func UploaderAll(engine string) map[string]Constructor
- func UploaderRegister(engine string, constructor Constructor)
- type Checker
- type Constructor
- type Responser
- type Sizer
- type Uploader
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultChecker = func(ctx echo.Context) (subdir string, name string, err error) { refid := ctx.Formx(`refid`).Uint64() timestamp := ctx.Formx(`time`).Int64() if ctx.Form(`token`) != middleware.Token(`refid`, refid, `time`, timestamp) { err = ctx.E(`令牌错误`) return } if time.Now().Local().Unix()-timestamp > UploadLinkLifeTime { err = ctx.E(`上传网址已过期`) return } subdir = fmt.Sprint(refid) + `/` return }
View Source
var DefaultResponser = func(ctx echo.Context, field string, err error, imageURLs []string) (result echo.H, embed bool) { return echo.H{ `files`: imageURLs, }, true }
View Source
var UploadLinkLifeTime int64 = 86400
UploadLinkLifeTime 上传链接生存时间
Functions ¶
func BatchUpload ¶
func CheckerAll ¶
func CheckerRegister ¶
func CleanTempFile ¶
CleanTempFile 清理临时文件
func ResponserAll ¶
func ResponserRegister ¶
func SubdirIsAllowed ¶
func SubdirRegister ¶
func UploaderAll ¶
func UploaderAll(engine string) map[string]Constructor
func UploaderRegister ¶
func UploaderRegister(engine string, constructor Constructor)
Types ¶
type Checker ¶
func CheckerGet ¶
type Constructor ¶
var DefaultConstructor Constructor
func UploaderGet ¶
func UploaderGet(engine string) Constructor
type Responser ¶
type Responser func(ctx echo.Context, field string, err error, imageURLs []string) (result echo.H, embed bool)
func ResponserGet ¶
type Uploader ¶
type Uploader interface { Engine() string Put(dst string, src io.Reader, size int64) (string, error) Get(file string) (io.ReadCloser, error) Delete(file string) error DeleteDir(dir string) error PublicURL(dst string) string FixURL(content string, embedded ...bool) string FixURLWithParams(content string, values url.Values, embedded ...bool) string }
Click to show internal directories.
Click to hide internal directories.