Initial commit: file_manager package with local and S3 support

This commit is contained in:
loveuer
2026-01-17 15:19:50 +08:00
commit f7160ce416
10 changed files with 1526 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
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()
}