mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: basic file validator
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user