Documentation
¶
Overview ¶
Package spaces provides an S3-compatible object storage client for DigitalOcean Spaces (or any S3-compatible endpoint) with presigned upload/download URLs, metadata lookup, ranged reads, and deletion.
All object keys are namespaced under the configured KeyPrefix and validated before use: keys containing "..", ".", or empty path segments, leading slashes, or control characters are rejected with ErrInvalidKey so callers cannot escape the prefix namespace (e.g. a per-tenant prefix).
Basic usage:
client, err := spaces.New(ctx, spaces.Options{
Region: "nyc3",
Endpoint: "https://nyc3.digitaloceanspaces.com",
Bucket: "my-bucket",
KeyPrefix: "tenant-42/",
AccessKey: accessKey,
SecretKey: secretKey,
})
if err != nil {
return err
}
url, err := client.PresignPut(ctx, "avatars/user.png", "image/png", size, 15*time.Minute)
Presign TTLs must be positive and at most MaxPresignTTL (7 days, the S3 protocol limit).
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Delete(ctx context.Context, logicalKey string) error
- func (c *Client) Head(ctx context.Context, logicalKey string) (*HeadResult, error)
- func (c *Client) PresignGet(ctx context.Context, logicalKey string, ttl time.Duration) (string, error)
- func (c *Client) PresignPut(ctx context.Context, logicalKey, contentType string, contentLength int64, ...) (string, error)
- func (c *Client) RangeGet(ctx context.Context, logicalKey string, maxBytes int64) ([]byte, error)
- type HeadResult
- type Options
Constants ¶
View Source
const MaxPresignTTL = 7 * 24 * time.Hour
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) PresignGet ¶
func (*Client) PresignPut ¶
type HeadResult ¶
Click to show internal directories.
Click to hide internal directories.