Cloudreve/pkg/filesystem/local/file.go

71 lines
1.1 KiB
Go
Raw Normal View History

2019-11-16 13:37:42 +08:00
package local
2019-11-17 19:12:10 +08:00
import (
"io"
"mime/multipart"
)
2019-11-16 13:37:42 +08:00
// FileData 上传的文件数据
type FileData struct {
File multipart.File
Size uint64
2019-11-16 16:05:10 +08:00
Name string
2019-11-16 13:37:42 +08:00
MIMEType string
}
func (file FileData) Read(p []byte) (n int, err error) {
2019-11-17 13:50:14 +08:00
return file.File.Read(p)
2019-11-16 13:37:42 +08:00
}
func (file FileData) GetMIMEType() string {
return file.MIMEType
}
func (file FileData) GetSize() uint64 {
return file.Size
}
func (file FileData) Close() error {
2019-11-17 13:50:14 +08:00
return file.File.Close()
2019-11-16 13:37:42 +08:00
}
2019-11-16 16:05:10 +08:00
func (file FileData) GetFileName() string {
return file.Name
}
2019-11-17 19:12:10 +08:00
func (file FileData) GetVirtualPath() string {
return file.Name
}
2019-11-17 19:12:10 +08:00
type FileStream struct {
File io.ReadCloser
Size uint64
VirtualPath string
Name string
MIMEType string
2019-11-17 19:12:10 +08:00
}
func (file FileStream) Read(p []byte) (n int, err error) {
return file.File.Read(p)
}
func (file FileStream) GetMIMEType() string {
return file.MIMEType
}
func (file FileStream) GetSize() uint64 {
return file.Size
}
func (file FileStream) Close() error {
return file.File.Close()
}
func (file FileStream) GetFileName() string {
return file.Name
}
func (file FileStream) GetVirtualPath() string {
return file.VirtualPath
}