Documentation
¶
Index ¶
- Constants
- type BatchObjectStorage
- type DownloadOpt
- type DownloadOption
- type ObjectInfo
- type ObjectStorage
- type Opt
- type Option
- type Reader
- type RemoveOpt
- type RemoveOption
- type S3Client
- func (c *S3Client) BatchDownload(ctx context.Context, keys []string, writers []io.WriterAt, opts ...DownloadOpt) error
- func (c *S3Client) BatchRead(ctx context.Context, keys []string, opts ...DownloadOpt) ([]Reader, error)
- func (c *S3Client) BatchSignDownloadReq(ctx context.Context, keys []string, opts ...SignOpt) ([]string, []http.Header, error)
- func (c *S3Client) BatchSignUploadReq(ctx context.Context, keys []string, opts ...SignOpt) ([]string, []http.Header, error)
- func (c *S3Client) BatchUpload(ctx context.Context, keys []string, readers []io.Reader, opts ...UploadOpt) error
- func (c *S3Client) Download(ctx context.Context, key string, writer io.WriterAt, opts ...DownloadOpt) error
- func (c *S3Client) Read(ctx context.Context, key string, opts ...DownloadOpt) (Reader, error)
- func (c *S3Client) Remove(ctx context.Context, key string, opts ...RemoveOpt) error
- func (c *S3Client) SignDownloadReq(ctx context.Context, key string, opts ...SignOpt) (url string, header http.Header, err error)
- func (c *S3Client) SignUploadReq(ctx context.Context, key string, opts ...SignOpt) (url string, header http.Header, err error)
- func (c *S3Client) Stat(ctx context.Context, key string, opts ...StatOpt) (*ObjectInfo, error)
- func (c *S3Client) Upload(ctx context.Context, key string, r io.Reader, opts ...UploadOpt) error
- type S3Config
- type S3Option
- type SignOpt
- type SignOption
- type StatOpt
- type StatOption
- type UploadOpt
- type UploadOption
Constants ¶
const ( DefaultCacheSizeGT = 64 << 10 DefaultUploadPartSize = 5 << 20 DefaultDownloadPartSize = 10 << 20 DefaultMaxObjectSize = 4 << 30 MinPartSize = s3manager.MinUploadPartSize DefaultConcurrency = 3 DefaultSignTTL = 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchObjectStorage ¶
type BatchObjectStorage interface { ObjectStorage BatchUpload(ctx context.Context, keys []string, readers []io.Reader, opts ...UploadOpt) error BatchDownload(ctx context.Context, keys []string, writers []io.WriterAt, opts ...DownloadOpt) error BatchRead(ctx context.Context, keys []string, opts ...DownloadOpt) ([]Reader, error) BatchSignDownloadReq(ctx context.Context, keys []string, opts ...SignOpt) (urls []string, headers []http.Header, err error) BatchSignUploadReq(ctx context.Context, keys []string, opts ...SignOpt) (urls []string, headers []http.Header, err error) }
type DownloadOpt ¶
type DownloadOpt = Opt
func DownloadWithBucket ¶
func DownloadWithBucket(bucket string) DownloadOpt
func DownloadWithConcurrency ¶
func DownloadWithConcurrency(concurrency int) DownloadOpt
func DownloadWithTimeout ¶
func DownloadWithTimeout(timeout time.Duration) DownloadOpt
type DownloadOption ¶
type DownloadOption = Option
func NewDownloadOption ¶
func NewDownloadOption(opts ...DownloadOpt) *DownloadOption
type ObjectInfo ¶
ObjectInfo represents the metadata of an object.
func NewObjectInfo ¶
func NewObjectInfo(name string, size int64, modTime time.Time, metadata map[string]string) *ObjectInfo
NewObjectInfo creates a new ObjectInfo.
func (*ObjectInfo) IsDir ¶
func (o *ObjectInfo) IsDir() bool
func (*ObjectInfo) ModTime ¶
func (o *ObjectInfo) ModTime() time.Time
func (*ObjectInfo) Mode ¶
func (o *ObjectInfo) Mode() fs.FileMode
func (*ObjectInfo) Name ¶
func (o *ObjectInfo) Name() string
func (*ObjectInfo) Size ¶
func (o *ObjectInfo) Size() int64
func (*ObjectInfo) Sys ¶
func (o *ObjectInfo) Sys() any
type ObjectStorage ¶
type ObjectStorage interface { Stat(ctx context.Context, key string, opts ...StatOpt) (*ObjectInfo, error) Upload(ctx context.Context, key string, r io.Reader, opts ...UploadOpt) error Download(ctx context.Context, key string, w io.WriterAt, opts ...DownloadOpt) error Read(ctx context.Context, key string, opts ...DownloadOpt) (Reader, error) Remove(ctx context.Context, key string, opts ...RemoveOpt) error SignUploadReq(ctx context.Context, key string, opts ...SignOpt) (url string, header http.Header, err error) SignDownloadReq(ctx context.Context, key string, opts ...SignOpt) (url string, header http.Header, err error) }
ObjectStorage defines the interface for object storage backend(e.g. S3, OSS, TOS etc.)
type Option ¶
func (*Option) ContextWithTimeout ¶
type RemoveOption ¶
type RemoveOption = Option
func NewRemoveOption ¶
func NewRemoveOption(opts ...RemoveOpt) *RemoveOption
type S3Client ¶
type S3Client struct {
// contains filtered or unexported fields
}
func NewS3Client ¶
func (*S3Client) BatchDownload ¶
func (*S3Client) BatchSignDownloadReq ¶
func (*S3Client) BatchSignUploadReq ¶
func (*S3Client) BatchUpload ¶
func (*S3Client) SignDownloadReq ¶
func (*S3Client) SignUploadReq ¶
type S3Config ¶
type S3Config struct { Endpoint string `json:"endpoint" yaml:"endpoint"` Region string `json:"region" yaml:"region"` Bucket string `json:"bucket" yaml:"bucket" validate:"required"` AccessKeyID string `json:"access_key_id" yaml:"access_key_id"` SecretAccessKey string `json:"secret_access_key" yaml:"secret_access_key"` // For download, if the size of the object is less than CacheSizeGT, it will be // read into memory, or else it will be downloaded to local file in parts. // Default is 64KB, must be greater than 0. CacheSizeGT int64 `json:"cache_size_gt" yaml:"cache_size_gt"` // For download, the size of each part. Default is 10MB, must be greater than 0. DownloadPartSize int64 `json:"download_part_size" yaml:"download_part_size"` // For upload, the size of each part. Default is 5MB, must be greater than 0. UploadPartSize int64 `json:"upload_part_size" yaml:"upload_part_size"` // The maximum size of the uploaded object. Default is 4GB, must be greater than // 0. MaxObjectSize int64 `json:"max_object_size" yaml:"max_object_size"` // If true, the path style will be used for the S3 endpoint. // If false, the virtual hosted-style will be used for the S3 endpoint. // Default is true. ForcePathStyle *bool `json:"force_path_style" yaml:"force_path_style"` }
func NewS3Config ¶
type SignOpt ¶
type SignOpt func(*SignOption)
func SignWithBucket ¶
SignWithBucket specifies the bucket for the signed URL. Default bucket is the bucket of the object storage.
func SignWithFormat ¶
SignWithFormat sets the format for the signed URL. Notice: not all backends support this option.
func SignWithImageTemplate ¶
SignWithImageTemplate sets the image template for the signed URL. Notice: not all backends support this option.
func SignWithTTL ¶
SignWithTTL specifies the TTL for the signed URL. Default TTL is 24 hours.
type SignOption ¶
func NewSignOption ¶
func NewSignOption(opts ...SignOpt) *SignOption
type StatOption ¶
type StatOption = Option
func NewStatOption ¶
func NewStatOption(opts ...StatOpt) *StatOption
type UploadOpt ¶
type UploadOpt func(*UploadOption)
func UploadWithBucket ¶
UploadWithBucket specifies the bucket for the upload. Default bucket is the bucket of the object storage.
func UploadWithConcurrency ¶
UploadWithConcurrency sets the concurrency for the upload. Default concurrency is 3, used in batch upload.
func UploadWithContentType ¶
UploadWithContentType sets the content_type for the upload. Default content_type is None.
func UploadWithMetadata ¶
UploadWithMetadata sets the metadata for the uploaded object.
type UploadOption ¶
type UploadOption struct { Bucket string Metadata map[string]string Concurrency int ContentTypes []string }
func NewUploadOption ¶
func NewUploadOption(opts ...UploadOpt) *UploadOption