Feat: client method to upload file from master node to slave node

This commit is contained in:
HFO4
2022-03-13 16:16:58 +08:00
parent 081e75146c
commit b96019be7c
12 changed files with 174 additions and 59 deletions

View File

@@ -32,9 +32,11 @@ type UploadTaskInfo struct {
type FileHeader interface {
io.Reader
io.Closer
io.Seeker
Info() *UploadTaskInfo
SetSize(uint64)
SetModel(fileModel interface{})
Seekable() bool
}
// FileStream 用户传来的文件
@@ -43,6 +45,7 @@ type FileStream struct {
LastModified *time.Time
Metadata map[string]string
File io.ReadCloser
Seeker io.Seeker
Size uint64
VirtualPath string
Name string
@@ -61,6 +64,14 @@ func (file *FileStream) Close() error {
return file.File.Close()
}
func (file *FileStream) Seek(offset int64, whence int) (int64, error) {
return file.Seeker.Seek(offset, whence)
}
func (file *FileStream) Seekable() bool {
return file.Seeker != nil
}
func (file *FileStream) Info() *UploadTaskInfo {
return &UploadTaskInfo{
Size: file.Size,