Documentation
¶
Index ¶
- type Client
- func (c *Client) CheckBucket(ctx context.Context) error
- func (c *Client) Get(ctx context.Context, key string) (*GetResult, error)
- func (c *Client) Head(ctx context.Context, key string) (*HeadResult, error)
- func (c *Client) List(ctx context.Context, prefix, continuationToken string) (*ListResult, error)
- func (c *Client) Put(ctx context.Context, key string, body io.Reader, contentType string, ...) error
- type GetResult
- type HeadResult
- type ListResult
- type ObjectInfo
- type PutOption
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 reads and writes objects in one bucket.
func New ¶
New builds a client for bucket. timeout is the deadline for each call. maxRetryAttempts is passed to the SDK as MaxAttempts, which counts the first attempt.
func (*Client) CheckBucket ¶ added in v0.15.0
CheckBucket confirms the bucket exists and the caller can reach it. A missing bucket wraps ErrNotFound.
func (*Client) Get ¶
Get returns the object at key. A missing key wraps ErrNotFound. The caller closes Body. Closing it ends the Get deadline.
func (*Client) Head ¶ added in v0.15.0
Head returns the metadata for key without downloading its body. A missing key wraps ErrNotFound.
S3 answers 404 for a missing bucket as well as a missing key, so a missing bucket also wraps ErrNotFound here. Call CheckBucket first when the two must be told apart.
func (*Client) List ¶
List returns one page of objects under prefix. An empty prefix lists the bucket. Pass the previous NextContinuationToken to read the next page. An empty page is success.
func (*Client) Put ¶
func (c *Client) Put(ctx context.Context, key string, body io.Reader, contentType string, opts ...PutOption) error
Put writes body to key, replacing any existing object. A seekable body lets the SDK set the content length. Pass WithMetadata to store user metadata alongside the object.
type GetResult ¶
type GetResult struct {
Body io.ReadCloser
ContentType string
Size int64
LastModified time.Time
Metadata map[string]string
}
GetResult is the body and metadata for one key. The caller closes Body. The Get deadline stays in effect until Body is closed. Metadata holds the user metadata set on the object, keyed without the x-amz-meta- prefix.
type HeadResult ¶ added in v0.15.0
type HeadResult struct {
ContentType string
Size int64
LastModified time.Time
Metadata map[string]string
}
HeadResult is the metadata for one key, read without its body. Metadata holds the user metadata set on the object, keyed without the x-amz-meta- prefix.
type ListResult ¶
type ListResult struct {
Objects []ObjectInfo
NextContinuationToken string
}
ListResult is one page of objects. NextContinuationToken is empty on the last page.
type ObjectInfo ¶
ObjectInfo is one key returned by List.
type PutOption ¶ added in v0.15.0
type PutOption func(*sdks3.PutObjectInput)
PutOption sets an optional field on a Put.
func WithMetadata ¶ added in v0.15.0
WithMetadata stores metadata as the object's user metadata, served back as x-amz-meta-<key> headers and returned by Get and Head. S3 lowercases the keys. It replaces any metadata the object had before, as Put replaces the whole object.