providers

package
v1.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

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 存储配置

func (*Config) Validate

func (c *Config) Validate() error

Validate 验证配置

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

type DirectUploadMismatch struct {
	Field    string
	Expected string
	Actual   string
}

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

type DirectUploadSize struct {
	Exact int64
	Min   int64
	Max   int64
}

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 DownloadOption

type DownloadOption struct{}

DownloadOption 下载选项

type DownloadOptionFunc

type DownloadOptionFunc func(*DownloadOption)

DownloadOptionFunc 下载选项函数

type MultipartUpload

type MultipartUpload struct {
	UploadID string
	Key      string
	Bucket   string
}

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 PartInfo

type PartInfo struct {
	PartNumber int
	ETag       string
}

PartInfo 分片信息

type SignOption

type SignOption struct {
	Method string
}

SignOption 签名选项

type SignOptionFunc

type SignOptionFunc func(*SignOption)

SignOptionFunc 签名选项函数

type UploadOption

type UploadOption struct {
	ContentType string
	Metadata    map[string]string
}

UploadOption 上传选项

type UploadOptionFunc

type UploadOptionFunc func(*UploadOption)

UploadOptionFunc 上传选项函数

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL