Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- type Config
- type DirectUploadAuthorization
- type DirectUploadAuthorizer
- type DirectUploadChecksum
- type DirectUploadChecksumAlgorithm
- type DirectUploadConstraints
- type DirectUploadMismatch
- type DirectUploadMode
- type DirectUploadRequest
- type DirectUploadSize
- type DirectUploadVerificationRequest
- type DirectUploadVerificationResult
- type DownloadOption
- type DownloadOptionFunc
- type MultipartUpload
- type ObjectInfo
- type PartInfo
- type SignOption
- type SignOptionFunc
- type UploadOption
- type UploadOptionFunc
Constants ¶
View Source
const ( TypeOSS = "oss" TypeCOS = "cos" TypeS3 = "s3" )
存储类型常量
Variables ¶
View Source
var ( ErrObjectNotFound = errors.New("storage/providers: object not found") ErrBucketNotFound = errors.New("storage/providers: bucket not found") ErrAccessDenied = errors.New("storage/providers: access denied") ErrUnsupportedDirectUploadMode = errors.New("storage/providers: unsupported direct upload mode") ErrUnsupportedDirectUploadConstraint = errors.New("storage/providers: unsupported direct upload constraint") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
Upload(ctx context.Context, key string, reader io.Reader, opts ...UploadOptionFunc) error
Download(ctx context.Context, key string, opts ...DownloadOptionFunc) (io.ReadCloser, error)
Delete(ctx context.Context, key string) error
Exists(ctx context.Context, key string) (bool, error)
Stat(ctx context.Context, key string) (*ObjectInfo, error)
SignedURL(ctx context.Context, key string, expire time.Duration, opts ...SignOptionFunc) (string, error)
InitMultipart(ctx context.Context, key string, opts ...UploadOptionFunc) (*MultipartUpload, error)
UploadPart(ctx context.Context, uploadID string, partNum int, reader io.Reader, opts ...UploadOptionFunc) (*PartInfo, error)
CompleteMultipart(ctx context.Context, uploadID string, parts []*PartInfo, opts ...UploadOptionFunc) error
AbortMultipart(ctx context.Context, uploadID string) error
DeleteBatch(ctx context.Context, keys []string) error
}
Client 存储客户端接口
type Config ¶
type Config struct {
Type string
AccessKeyID string
AccessKeySecret string
Bucket string
Region string
Endpoint string
DefaultSignExpire time.Duration
}
Config 存储配置
type DirectUploadAuthorization ¶ added in v1.3.3
type DirectUploadAuthorization struct {
Provider string
Mode DirectUploadMode
ObjectKey string
URL string
Method string
Headers map[string]string
FormFields map[string]string
ExpiresAt time.Time
Constraints DirectUploadConstraints
}
DirectUploadAuthorization 描述客户端直传授权结果。
type DirectUploadAuthorizer ¶ added in v1.3.3
type DirectUploadAuthorizer interface {
AuthorizeDirectUpload(ctx context.Context, req DirectUploadRequest) (*DirectUploadAuthorization, error)
}
DirectUploadAuthorizer 描述 provider 级直传授权能力。
type DirectUploadChecksum ¶ added in v1.3.3
type DirectUploadChecksum struct {
Algorithm DirectUploadChecksumAlgorithm
Value string
}
DirectUploadChecksum 描述客户端直传的内容校验约束。
type DirectUploadChecksumAlgorithm ¶ added in v1.3.3
type DirectUploadChecksumAlgorithm string
DirectUploadChecksumAlgorithm 描述客户端直传校验算法。
const ( DirectUploadChecksumMD5 DirectUploadChecksumAlgorithm = "md5" DirectUploadChecksumSHA256 DirectUploadChecksumAlgorithm = "sha256" )
type DirectUploadConstraints ¶ added in v1.3.3
type DirectUploadConstraints struct {
ContentType string
Metadata map[string]string
Size *DirectUploadSize
Checksum *DirectUploadChecksum
}
DirectUploadConstraints 描述实际生效的上传约束。
type DirectUploadMismatch ¶ added in v1.3.3
DirectUploadMismatch 描述对象事实与期望约束的不匹配项。
type DirectUploadMode ¶ added in v1.3.3
type DirectUploadMode string
DirectUploadMode 客户端直传授权模式。
const ( DirectUploadModeAuto DirectUploadMode = "auto" DirectUploadModePut DirectUploadMode = "put" DirectUploadModePost DirectUploadMode = "post" )
type DirectUploadRequest ¶ added in v1.3.3
type DirectUploadRequest struct {
ObjectKey string
Expire time.Duration
ContentType string
Metadata map[string]string
Size *DirectUploadSize
Checksum *DirectUploadChecksum
Mode DirectUploadMode
}
DirectUploadRequest 描述客户端直传授权请求。
type DirectUploadSize ¶ added in v1.3.3
DirectUploadSize 描述客户端直传的对象大小约束。
type DirectUploadVerificationRequest ¶ added in v1.3.3
type DirectUploadVerificationRequest struct {
ObjectKey string
ContentType string
Metadata map[string]string
Size *DirectUploadSize
Checksum *DirectUploadChecksum
}
DirectUploadVerificationRequest 描述上传后对象校验请求。
type DirectUploadVerificationResult ¶ added in v1.3.3
type DirectUploadVerificationResult struct {
Exists bool
Matched bool
Mismatches []DirectUploadMismatch
Object *ObjectInfo
}
DirectUploadVerificationResult 描述上传后对象校验结果。
type MultipartUpload ¶
MultipartUpload 分片上传信息
type ObjectInfo ¶
type ObjectInfo struct {
Key string
Size int64
LastModified time.Time
ETag string
ContentType string
Metadata map[string]string
Checksums map[string]string
}
ObjectInfo 对象元数据
type UploadOption ¶
UploadOption 上传选项
Click to show internal directories.
Click to hide internal directories.