Feat: basic file validator

This commit is contained in:
HFO4
2019-11-16 16:05:10 +08:00
parent 003274162b
commit 79caf635f9
9 changed files with 178 additions and 6 deletions

View File

@@ -11,18 +11,37 @@ type FileData interface {
io.Closer
GetSize() uint64
GetMIMEType() string
GetFileName() string
}
// FileSystem 管理文件的文件系统
type FileSystem struct {
// 文件系统所有者
/*
文件系统所有者
*/
User *model.User
// 文件系统处理适配器
/*
钩子函数
*/
// 上传文件前
BeforeUpload func(fs *FileSystem, file FileData) error
// 上传文件后
AfterUpload func(fs *FileSystem) error
// 文件验证失败后
ValidateFailed func(fs *FileSystem) error
/*
文件系统处理适配器
*/
}
// Upload 上传文件
func (fs *FileSystem) Upload(File FileData) (err error) {
func (fs *FileSystem) Upload(file FileData) (err error) {
err = fs.BeforeUpload(fs, file)
if err != nil {
return err
}
return nil
}