Documentation
¶
Index ¶
- type Client
- func (c *Client) Get(ctx context.Context, key string, rangeHeader *string) (io.ReadCloser, *ObjectMetadata, error)
- func (c *Client) Head(ctx context.Context, key string) (*ObjectMetadata, error)
- func (c *Client) List(ctx context.Context, prefix string) ([]ListResult, error)
- func (c *Client) ListPages(ctx context.Context, prefix string, fn func([]ListResult) bool) error
- func (c *Client) Presign(ctx context.Context, key string, ttl time.Duration) (string, error)
- func (c *Client) Put(ctx context.Context, key string, r io.Reader, contentType *string) (*PutResult, error)
- type Config
- type ListResult
- type ObjectMetadata
- type PutResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a generic S3 client that works with any S3-compatible storage.
func NewClientWithContext ¶ added in v1.1.0
NewClientWithContext creates a new S3 client with the given configuration and context.
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context, key string, rangeHeader *string) (io.ReadCloser, *ObjectMetadata, error)
Get retrieves an object from the bucket. If rangeHeader is not nil, it must be a valid HTTP Range header (e.g., "bytes=0-1023"). The caller is responsible for closing the returned ReadCloser.
func (*Client) List ¶ added in v1.0.1
List returns all objects with the given prefix, automatically handling pagination. Warning: for buckets with millions of objects, this method may consume a lot of memory. For such cases, consider using ListPages for iterative processing.
func (*Client) ListPages ¶ added in v1.1.0
ListPages iterates over objects with the given prefix, calling the provided function for each page of results. The function should return true to continue, false to stop. This method is memory-efficient for large buckets.
type Config ¶
type Config struct {
// Endpoint — URL хранилища. Оставьте пустым для AWS S3.
// Пример: "https://storage.yandexcloud.net"
Endpoint string
// Region — регион хранилища. Например: "ru-central1", "us-east-1".
Region string
// AccessKey — access key для аутентификации.
AccessKey string
// SecretKey — secret key для аутентификации.
SecretKey string
// Bucket — имя бакета, с которым работает клиент.
Bucket string
// ForcePathStyle — использовать path-style URLs вместо virtual-hosted-style.
// Требуется для MinIO и большинства S3-совместимых хранилищ.
ForcePathStyle bool
}
Config содержит настройки подключения к S3-совместимому хранилищу.
type ListResult ¶ added in v1.0.1
ListResult represents a single object returned by List.