mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-27 18:11:57 +08:00
Refactor: create placeholder file and record upload session id in it
This commit is contained in:
@@ -15,80 +15,62 @@ const (
|
||||
Nop
|
||||
)
|
||||
|
||||
// FileHeader 上传来的文件数据处理器
|
||||
type FileHeader interface {
|
||||
io.Reader
|
||||
io.Closer
|
||||
Info() *UploadTaskInfo
|
||||
SetSize(uint64)
|
||||
}
|
||||
|
||||
type UploadTaskInfo struct {
|
||||
Size uint64
|
||||
MIMEType string
|
||||
FileName string
|
||||
VirtualPath string
|
||||
Mode WriteMode
|
||||
Metadata map[string]string
|
||||
LastModified *time.Time
|
||||
SavePath string
|
||||
UploadSessionID *string
|
||||
}
|
||||
|
||||
// FileStream 用户传来的文件
|
||||
type FileStream struct {
|
||||
Mode WriteMode
|
||||
Hidden bool
|
||||
LastModified *time.Time
|
||||
Metadata map[string]string
|
||||
File io.ReadCloser
|
||||
Size uint64
|
||||
VirtualPath string
|
||||
Name string
|
||||
MIMEType string
|
||||
SavePath string
|
||||
Mode WriteMode
|
||||
LastModified *time.Time
|
||||
Metadata map[string]string
|
||||
File io.ReadCloser
|
||||
Size uint64
|
||||
VirtualPath string
|
||||
Name string
|
||||
MIMEType string
|
||||
SavePath string
|
||||
UploadSessionID *string
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
func (file *FileStream) GetMode() WriteMode {
|
||||
return file.Mode
|
||||
}
|
||||
|
||||
func (file *FileStream) GetMetadata() map[string]string {
|
||||
return file.Metadata
|
||||
}
|
||||
|
||||
func (file *FileStream) GetLastModified() *time.Time {
|
||||
return file.LastModified
|
||||
}
|
||||
|
||||
func (file *FileStream) IsHidden() bool {
|
||||
return file.Hidden
|
||||
}
|
||||
|
||||
func (file *FileStream) GetSavePath() string {
|
||||
return file.SavePath
|
||||
func (file *FileStream) Info() *UploadTaskInfo {
|
||||
return &UploadTaskInfo{
|
||||
Size: file.Size,
|
||||
MIMEType: file.MIMEType,
|
||||
FileName: file.Name,
|
||||
VirtualPath: file.VirtualPath,
|
||||
Mode: file.Mode,
|
||||
Metadata: file.Metadata,
|
||||
LastModified: file.LastModified,
|
||||
SavePath: file.SavePath,
|
||||
UploadSessionID: file.UploadSessionID,
|
||||
}
|
||||
}
|
||||
|
||||
func (file *FileStream) SetSize(size uint64) {
|
||||
file.Size = size
|
||||
}
|
||||
|
||||
// FileHeader 上传来的文件数据处理器
|
||||
type FileHeader interface {
|
||||
io.Reader
|
||||
io.Closer
|
||||
GetSize() uint64
|
||||
GetMIMEType() string
|
||||
GetFileName() string
|
||||
GetVirtualPath() string
|
||||
GetMode() WriteMode
|
||||
GetMetadata() map[string]string
|
||||
GetLastModified() *time.Time
|
||||
IsHidden() bool
|
||||
GetSavePath() string
|
||||
SetSize(uint64)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user