Documentation ¶
Index ¶
- Variables
- func BackendURL() string
- func BackendUploadURL(subdir string, values ...interface{}) string
- func BatchUpload(ctx echo.Context, fieldName string, ...) (results uploadClient.Results, err error)
- func CheckerAll() map[string]Checker
- func CheckerRegister(typ string, checker Checker)
- func CleanTempFile(prefix string, deleter func(folderPath string) error) error
- func DBSaverRegister(key string, dbsaver DBSaver)
- func FrontendURL() string
- func FrontendUploadURL(subdir string, values ...interface{}) string
- func ResponserAll() map[string]Responser
- func ResponserRegister(field string, responser Responser)
- func StorerAll(engine string) map[string]Constructor
- func StorerRegister(engine string, constructor Constructor)
- func SubdirAll() map[string]bool
- func SubdirIsAllowed(subdir string) bool
- func SubdirRegister(subdir string, allow bool)
- func Token(values ...interface{}) string
- func URLParam(subdir string, values ...interface{}) string
- type APIKey
- type Checker
- type Constructor
- type DBSaver
- type Responser
- type Sizer
- type Storer
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //BackendUploadPath 后台上传网址路径 BackendUploadPath = `/manager/upload` //FrontendUploadPath 前台上传网址路径 FrontendUploadPath = `/user/upload` //SetURLParamDefaultValue 设置参数默认值 SetURLParamDefaultValue func(*url.Values) )
View Source
var DefaultChecker = func(ctx echo.Context, tis table.TableInfoStorer) (subdir string, name string, err error) { refid := ctx.Formx(`refid`).Uint64() timestamp := ctx.Formx(`time`).Int64() if ctx.Form(`token`) != Token(`refid`, refid, `time`, timestamp) { err = ctx.E(`令牌错误`) return } if time.Now().Local().Unix()-timestamp > UploadLinkLifeTime { err = ctx.E(`上传网址已过期`) return } subdir = fmt.Sprint(refid) + `/` tis.SetTableID(refid) return }
View Source
var ( DefaultDBSaver = func(fileM *modelFile.File, result *uploadClient.Result, reader io.Reader) error { return nil } )
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 (
ErrExistsFile = table.ErrExistsFile
)
View Source
var UploadLinkLifeTime int64 = 86400
UploadLinkLifeTime 上传链接生存时间
Functions ¶
func BackendUploadURL ¶
BackendUploadURL 构建后台上传网址
func BatchUpload ¶
func CheckerAll ¶
func CheckerRegister ¶
func CleanTempFile ¶
CleanTempFile 清理临时文件
func DBSaverRegister ¶
func FrontendUploadURL ¶
FrontendUploadURL 构建前台上传网址
func ResponserAll ¶
func ResponserRegister ¶
func StorerAll ¶
func StorerAll(engine string) map[string]Constructor
func StorerRegister ¶
func StorerRegister(engine string, constructor Constructor)
func SubdirIsAllowed ¶
func SubdirRegister ¶
Types ¶
type Checker ¶
func CheckerGet ¶
type Constructor ¶
var DefaultConstructor Constructor
func StorerGet ¶
func StorerGet(engine string) Constructor
type DBSaver ¶
func DBSaverGet ¶
type Responser ¶
type Responser func(ctx echo.Context, field string, err error, imageURLs []string) (result echo.H, embed bool)
func ResponserGet ¶
type Storer ¶
type Storer interface { Engine() string Put(dst string, src io.Reader, size int64) (savePath string, viewURL string, err error) Get(file string) (io.ReadCloser, error) Exists(file string) (bool, error) FileInfo(file string) (os.FileInfo, error) SendFile(ctx echo.Context, file string) error Delete(file string) error DeleteDir(dir string) error PublicURL(dst string) string URLToFile(viewURL string) string FixURL(content string, embedded ...bool) string FixURLWithParams(content string, values url.Values, embedded ...bool) string Close() error }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.