You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudreve/pkg/filesystem/filesystem.go

48 lines
786 B

5 years ago
package filesystem
import (
"github.com/HFO4/cloudreve/models"
5 years ago
"io"
)
// FileData 上传来的文件数据处理器
type FileData interface {
io.Reader
io.Closer
GetSize() uint64
GetMIMEType() string
GetFileName() string
5 years ago
}
// FileSystem 管理文件的文件系统
type FileSystem struct {
/*
*/
5 years ago
User *model.User
/*
*/
// 上传文件前
BeforeUpload func(fs *FileSystem, file FileData) error
// 上传文件后
AfterUpload func(fs *FileSystem) error
// 文件验证失败后
ValidateFailed func(fs *FileSystem) error
/*
*/
5 years ago
}
// Upload 上传文件
func (fs *FileSystem) Upload(file FileData) (err error) {
err = fs.BeforeUpload(fs, file)
if err != nil {
return err
}
5 years ago
return nil
}