objclient

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// The caller should close the returned reader when done.
	Read(ctx context.Context, key string) (io.ReadCloser, error)
	// The WriteOptions can be empty for OSS clients. But caller must set the
	// Size option for S3 clients.
	Write(ctx context.Context, key string, r io.Reader, o *WriteOptions) error
	Exist(ctx context.Context, key string) (bool, error)
	Remove(ctx context.Context, keys ...string) error

	// Empty prefix will list every objects in the bucket. Otherwise, the
	// prefix should end with a "/".
	List(ctx context.Context, prefix string) ([]ObjectItem, error)
	Info(ctx context.Context, key string) (*ObjectInfo, error)
	Copy(ctx context.Context, src, dst string) error
}

func NewOSSClient

func NewOSSClient(config OSSConfig) (Client, error)

func NewS3Client

func NewS3Client(config S3Config) (Client, error)

type OSSClient

type OSSClient struct {
	// contains filtered or unexported fields
}

func (*OSSClient) Copy

func (client *OSSClient) Copy(ctx context.Context, src, dst string) error

func (*OSSClient) Exist

func (client *OSSClient) Exist(ctx context.Context, key string) (bool, error)

func (*OSSClient) Info

func (client *OSSClient) Info(ctx context.Context, key string) (*ObjectInfo, error)

func (*OSSClient) List

func (client *OSSClient) List(ctx context.Context, prefix string) ([]ObjectItem, error)

func (*OSSClient) Read

func (client *OSSClient) Read(ctx context.Context, key string) (io.ReadCloser, error)

func (*OSSClient) Remove

func (client *OSSClient) Remove(ctx context.Context, keys ...string) error

func (*OSSClient) Write

func (client *OSSClient) Write(ctx context.Context, key string, r io.Reader, o *WriteOptions) error

type OSSConfig

type OSSConfig struct {
	Endpoint string
	Region   string
	HTTPS    string
	Bucket   string
	KeyID    string
	Key      string
}

type ObjectInfo

type ObjectInfo struct {
	Size         int64
	LastModified time.Time
	Metadata     map[string]string
}

type ObjectItem

type ObjectItem struct {
	Key          string
	Size         int64
	LastModified time.Time
}

type S3Client

type S3Client struct {
	// contains filtered or unexported fields
}

func (*S3Client) Copy

func (client *S3Client) Copy(ctx context.Context, src, dst string) error

func (*S3Client) Exist

func (client *S3Client) Exist(ctx context.Context, key string) (bool, error)

func (*S3Client) Info

func (client *S3Client) Info(ctx context.Context, key string) (*ObjectInfo, error)

func (*S3Client) List

func (client *S3Client) List(ctx context.Context, prefix string) ([]ObjectItem, error)

func (*S3Client) Read

func (client *S3Client) Read(ctx context.Context, key string) (io.ReadCloser, error)

func (*S3Client) Remove

func (client *S3Client) Remove(ctx context.Context, keys ...string) error

func (*S3Client) Write

func (client *S3Client) Write(ctx context.Context, key string, r io.Reader, o *WriteOptions) error

type S3Config

type S3Config struct {
	Endpoint         string
	Region           string
	HTTPS            string
	Bucket           string
	PathStyleRequest string
	KeyID            string
	Key              string
	V4Signature      string
	SSECKey          string
}

type TimeoutReader

type TimeoutReader struct {
	// contains filtered or unexported fields
}

TimeoutReader will call the cancel function if Read() was blocked for about 30 seconds.

func (*TimeoutReader) Close

func (reader *TimeoutReader) Close() error

func (*TimeoutReader) Read

func (reader *TimeoutReader) Read(data []byte) (int, error)

type WriteOptions

type WriteOptions struct {
	// Size is required for S3 clients.
	Size int64
	// Metadata is optional. Keys should be lower case.
	Metadata map[string]string
}

Jump to

Keyboard shortcuts

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