Documentation
¶
Index ¶
- type BucketItem
- type Client
- type CopyRequest
- type CreateFolderRequest
- type ListObjectsRequest
- type ListObjectsResult
- type ObjectItem
- type ObjectRequest
- type PresignRequest
- type RemoveObjectsRequest
- type Service
- func (s *Service) CopyObject(ctx context.Context, req *CopyRequest) error
- func (s *Service) CreateFolder(ctx context.Context, req *CreateFolderRequest) error
- func (s *Service) GetObject(ctx context.Context, assetID int64, bucket, key string) (io.ReadCloser, int64, error)
- func (s *Service) ListBuckets(ctx context.Context, assetID int64) ([]BucketItem, error)
- func (s *Service) ListObjects(ctx context.Context, req *ListObjectsRequest) (*ListObjectsResult, error)
- func (s *Service) MoveObject(ctx context.Context, req *CopyRequest) error
- func (s *Service) PresignGet(ctx context.Context, req *PresignRequest) (string, error)
- func (s *Service) PresignPut(ctx context.Context, req *PresignRequest) (string, error)
- func (s *Service) PutObject(ctx context.Context, assetID int64, bucket, key string, r io.Reader, ...) error
- func (s *Service) RemoveObject(ctx context.Context, req *ObjectRequest) error
- func (s *Service) RemoveObjects(ctx context.Context, req *RemoveObjectsRequest) error
- func (s *Service) StatObject(ctx context.Context, req *ObjectRequest) (*ObjectItem, error)
- func (s *Service) TestConfig(ctx context.Context, cfg *asset_entity.OSSConfig, secret string) error
- func (s *Service) TestConnection(ctx context.Context, assetID int64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BucketItem ¶
BucketItem 是账号下的一个 Bucket。
type Client ¶
type Client interface {
ListBuckets(ctx context.Context) ([]BucketItem, error)
// ListObjects 分页契约:maxKeys<=0 表示"使用服务端默认值";当超出 maxKeys 还有更多对象时,
// 实现必须多返回 1 条(即最多返回 maxKeys+1 条),调用方(listObjectsWith)靠这多出的一条
// 判断 IsTruncated 并截断结果——若实现只按字面返回恰好 maxKeys 条,截断检测会永远为 false,
// 分页将在"假的最后一页"上卡死。
ListObjects(ctx context.Context, bucket, prefix string, maxKeys int, startAfter string) ([]ObjectItem, error)
StatObject(ctx context.Context, bucket, key string) (ObjectItem, error)
RemoveObject(ctx context.Context, bucket, key string) error
CopyObject(ctx context.Context, srcBucket, srcKey, dstBucket, dstKey string) error
RemoveObjects(ctx context.Context, bucket string, keys []string) error
PutObject(ctx context.Context, bucket, key string, r io.Reader, size int64, contentType string) error
GetObject(ctx context.Context, bucket, key string) (io.ReadCloser, int64, error)
PresignGet(ctx context.Context, bucket, key string, expiry time.Duration) (string, error)
PresignPut(ctx context.Context, bucket, key string, expiry time.Duration) (string, error)
BucketExists(ctx context.Context, bucket string) (bool, error)
}
Client 是服务依赖的窄对象存储接口(可 mock)。
type CopyRequest ¶
type CreateFolderRequest ¶
type ListObjectsRequest ¶
type ListObjectsResult ¶
type ListObjectsResult struct {
Prefixes []string `json:"prefixes"`
Objects []ObjectItem `json:"objects"`
NextContinuationToken string `json:"nextContinuationToken"`
IsTruncated bool `json:"isTruncated"`
}
type ObjectItem ¶
type ObjectItem struct {
Key string `json:"key"`
Size int64 `json:"size"`
LastModified int64 `json:"lastModified"`
ETag string `json:"etag"`
StorageClass string `json:"storageClass"`
ContentType string `json:"contentType"`
IsPrefix bool `json:"isPrefix"`
}
ObjectItem 是 Bucket 下的一个对象或"文件夹"前缀。
type ObjectRequest ¶
type PresignRequest ¶
type RemoveObjectsRequest ¶
type Service ¶
type Service struct{}
func (*Service) CopyObject ¶
func (s *Service) CopyObject(ctx context.Context, req *CopyRequest) error
func (*Service) CreateFolder ¶
func (s *Service) CreateFolder(ctx context.Context, req *CreateFolderRequest) error
func (*Service) GetObject ¶
func (s *Service) GetObject(ctx context.Context, assetID int64, bucket, key string) (io.ReadCloser, int64, error)
GetObject 是给 app 层流式下载用的原语:connect 后返回对象流 + 总大小。
func (*Service) ListBuckets ¶
func (*Service) ListObjects ¶
func (s *Service) ListObjects(ctx context.Context, req *ListObjectsRequest) (*ListObjectsResult, error)
func (*Service) MoveObject ¶
func (s *Service) MoveObject(ctx context.Context, req *CopyRequest) error
func (*Service) PresignGet ¶
func (*Service) PresignPut ¶
func (*Service) PutObject ¶
func (s *Service) PutObject(ctx context.Context, assetID int64, bucket, key string, r io.Reader, size int64, contentType string) error
PutObject 是给 app 层流式上传用的原语:connect 后把(通常已包进度)reader 写入对象。
func (*Service) RemoveObject ¶
func (s *Service) RemoveObject(ctx context.Context, req *ObjectRequest) error
func (*Service) RemoveObjects ¶
func (s *Service) RemoveObjects(ctx context.Context, req *RemoveObjectsRequest) error
func (*Service) StatObject ¶
func (s *Service) StatObject(ctx context.Context, req *ObjectRequest) (*ObjectItem, error)
func (*Service) TestConfig ¶
TestConfig 验证一份未保存的配置(表单"测试连接")。
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mock_ossclient is a generated GoMock package.
|
Package mock_ossclient is a generated GoMock package. |
Click to show internal directories.
Click to hide internal directories.