-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstorage_interface.go
More file actions
29 lines (25 loc) · 1.33 KB
/
storage_interface.go
File metadata and controls
29 lines (25 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main
import (
"context"
"github.com/minio/minio-go/v7"
)
// ObjectStorageClient 对象存储客户端接口
// 抽象 minio.Client 的核心方法,便于单元测试时使用 Mock 替换
type ObjectStorageClient interface {
// ListBuckets 列出所有 Bucket
ListBuckets(ctx context.Context) ([]minio.BucketInfo, error)
// BucketExists 判断 Bucket 是否存在
BucketExists(ctx context.Context, bucketName string) (bool, error)
// StatObject 获取对象元信息
StatObject(ctx context.Context, bucketName, objectName string, opts minio.StatObjectOptions) (minio.ObjectInfo, error)
// FPutObject 上传文件到对象存储
FPutObject(ctx context.Context, bucketName, objectName, filePath string, opts minio.PutObjectOptions) (minio.UploadInfo, error)
// RemoveObject 删除单个对象
RemoveObject(ctx context.Context, bucketName, objectName string, opts minio.RemoveObjectOptions) error
// ListObjects 列出对象
ListObjects(ctx context.Context, bucketName string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo
// RemoveObjects 批量删除对象
RemoveObjects(ctx context.Context, bucketName string, objectsCh <-chan minio.ObjectInfo, opts minio.RemoveObjectsOptions) <-chan minio.RemoveObjectError
}
// 确保 minio.Client 实现了 ObjectStorageClient 接口
var _ ObjectStorageClient = (*minio.Client)(nil)