35 lines
977 B
Go
35 lines
977 B
Go
package file_manager
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"time"
|
|
)
|
|
|
|
// FileInfo 文件信息
|
|
type FileInfo struct {
|
|
Filename string `json:"filename"`
|
|
Size int64 `json:"size"`
|
|
SHA256 string `json:"sha256,omitempty"`
|
|
Path string `json:"path"`
|
|
CreateTime time.Time `json:"create_time"`
|
|
Complete bool `json:"complete"`
|
|
}
|
|
|
|
// CreateResult 创建文件结果
|
|
type CreateResult struct {
|
|
Code string `json:"code"`
|
|
SHA256 string `json:"sha256,omitempty"`
|
|
}
|
|
|
|
// FileManager 文件管理接口
|
|
type FileManager interface {
|
|
Create(ctx context.Context, filename string, size int64, sha256 string) (*CreateResult, error)
|
|
Upload(ctx context.Context, code string, start int64, end int64, reader io.Reader) (total int64, size int64, err error)
|
|
Get(ctx context.Context, code string) ([]byte, error)
|
|
Close(code string) error
|
|
GetInfo(ctx context.Context, code string) (*FileInfo, error)
|
|
Delete(ctx context.Context, code string) error
|
|
CloseManager()
|
|
}
|