Files
2026-03-09 11:44:51 +08:00

58 lines
1.7 KiB
Go

package storagex
import (
"context"
"errors"
"io"
"time"
)
// Config 通用配置结构 (可根据需要扩展)
type Config struct {
Provider string // 服务商: "aliyun", "aws", "tencent"
AccountID string // 账号标识: "account_01", "finance_team"
Options map[string]string // 具体配置: AK, SK, Bucket, Region, Endpoint 等
}
// PutResult 上传成功后的返回信息
type PutResult struct {
URL string // 文件访问地址
Size int64 // 文件大小
ETag string // 文件指纹/哈希
Provider string // 服务商名称
AccountID string // 使用的账号ID(用于追踪)
}
type Uploader interface {
// GetObject 获取对象
GetObject(ctx context.Context, objectKey string) (io.ReadCloser, error)
// GetUrl 获取对象URL地址
GetUrl(ctx context.Context, objectKey string, expire time.Duration) (string, error)
// PutObject 写入对象
PutObject(ctx context.Context, objectKey string, value io.Reader) (*PutResult, error)
// DeleteObject 删除对象
DeleteObject(ctx context.Context, objectKey string) error
}
type UploaderImpl struct{}
func NewUploader() *UploaderImpl {
return &UploaderImpl{}
}
func (o *UploaderImpl) GetObject(ctx context.Context, objectKey string) (io.ReadCloser, error) {
return nil, errors.New("not implemented")
}
func (o *UploaderImpl) PutObject(ctx context.Context, objectKey string, value io.Reader) (*PutResult, error) {
return nil, errors.New("not implemented")
}
func (o *UploaderImpl) GetUrl(ctx context.Context, objectKey string, expire time.Duration) (string, error) {
return "", errors.New("not implemented")
}
func (o *UploaderImpl) DeleteObject(ctx context.Context, objectKey string) error {
return errors.New("not implemented")
}