mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Add: filesystem
This commit is contained in:
28
pkg/filesystem/filesystem.go
Normal file
28
pkg/filesystem/filesystem.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package filesystem
|
||||
|
||||
import (
|
||||
"cloudreve/models"
|
||||
"io"
|
||||
)
|
||||
|
||||
// FileData 上传来的文件数据处理器
|
||||
type FileData interface {
|
||||
io.Reader
|
||||
io.Closer
|
||||
GetSize() uint64
|
||||
GetMIMEType() string
|
||||
}
|
||||
|
||||
// FileSystem 管理文件的文件系统
|
||||
type FileSystem struct {
|
||||
// 文件系统所有者
|
||||
User *model.User
|
||||
|
||||
// 文件系统处理适配器
|
||||
|
||||
}
|
||||
|
||||
// Upload 上传文件
|
||||
func (fs *FileSystem) Upload(File FileData) (err error) {
|
||||
return nil
|
||||
}
|
||||
26
pkg/filesystem/local/file.go
Normal file
26
pkg/filesystem/local/file.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package local
|
||||
|
||||
import "mime/multipart"
|
||||
|
||||
// FileData 上传的文件数据
|
||||
type FileData struct {
|
||||
File multipart.File
|
||||
Size uint64
|
||||
MIMEType string
|
||||
}
|
||||
|
||||
func (file FileData) Read(p []byte) (n int, err error) {
|
||||
return file.Read(p)
|
||||
}
|
||||
|
||||
func (file FileData) GetMIMEType() string {
|
||||
return file.MIMEType
|
||||
}
|
||||
|
||||
func (file FileData) GetSize() uint64 {
|
||||
return file.Size
|
||||
}
|
||||
|
||||
func (file FileData) Close() error {
|
||||
return file.Close()
|
||||
}
|
||||
1
pkg/filesystem/local/local.go
Normal file
1
pkg/filesystem/local/local.go
Normal file
@@ -0,0 +1 @@
|
||||
package local
|
||||
Reference in New Issue
Block a user