Documentation
¶
Index ¶
- func EscapePath(key string) string
- func HashBody(body io.ReadSeeker) (sum []byte, length int64, err error)
- func SSECHeaders(keyBytes []byte) map[string]string
- type Client
- func (c *Client) Authorize(method, reqURL string, headers map[string]string, payloadHash string, ...) string
- func (c *Client) CopyObject(ctx context.Context, srcKey, dstKey string, headers map[string]string) error
- func (c *Client) DeleteObject(ctx context.Context, key string) error
- func (c *Client) Do(ctx context.Context, method, key string, body io.ReadSeeker, ...) error
- func (c *Client) ObjectURL(key string) string
- func (c *Client) PutObject(ctx context.Context, key string, body io.ReadSeeker, contentType string, ...) error
- func (c *Client) SigningKey(date string) []byte
- type Config
- type Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapePath ¶
EscapePath percent-encodes key preserving '/' separators per SigV4 rules.
func HashBody ¶
func HashBody(body io.ReadSeeker) (sum []byte, length int64, err error)
HashBody computes the SHA256 of body without buffering all content in heap memory, then seeks back to the starting offset.
func SSECHeaders ¶
SSECHeaders returns standard S3 customer-provided encryption headers.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client executes S3-compatible API requests using AWS SigV4 signing.
func (*Client) Authorize ¶
func (c *Client) Authorize(method, reqURL string, headers map[string]string, payloadHash string, now time.Time) string
Authorize computes the Authorization header for a request.
func (*Client) CopyObject ¶
func (c *Client) CopyObject(ctx context.Context, srcKey, dstKey string, headers map[string]string) error
CopyObject copies an object from srcKey to dstKey.
func (*Client) DeleteObject ¶
DeleteObject deletes an object key from the S3 bucket.
func (*Client) Do ¶
func (c *Client) Do(ctx context.Context, method, key string, body io.ReadSeeker, contentType string, extraHeaders map[string]string) error
Do executes an S3 request with SigV4 authorization and retries on retryable errors.
func (*Client) PutObject ¶
func (c *Client) PutObject(ctx context.Context, key string, body io.ReadSeeker, contentType string, headers map[string]string) error
PutObject uploads an object key to the S3 bucket.
func (*Client) SigningKey ¶
SigningKey returns the derived signing key for a given scope date (YYYYMMDD). Results are cached across calls on the same date.
type Config ¶
type Config struct {
Endpoint string // e.g. "https://s3.us-east-1.amazonaws.com" or "https://s3.us-west-004.backblazeb2.com"
Region string // e.g. "us-east-1"
Bucket string
AccessKey string
SecretKey string
UsePathStyle bool // Set true for MinIO or path-style endpoints
HTTPClient *http.Client
}
Config defines connection coordinates and credentials for the S3 client.