Documentation
¶
Overview ¶
Package storage reads and writes the objects in an app's buckets, with the app's own S3 credentials (the Secret maxcloud-s3 the controller keeps in its namespace).
Index ¶
- func Base(key string) string
- type Client
- func (c *Client) Bucket(name string) string
- func (c *Client) Delete(ctx context.Context, name string, keys []string) error
- func (c *Client) Download(ctx context.Context, name, key, file string, w io.Writer) (int64, error)
- func (c *Client) List(ctx context.Context, name, prefix string, recursive bool, ...) error
- func (c *Client) Upload(ctx context.Context, name, key, file string) (int64, error)
- type Object
- type Ref
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// App is the app's name; its buckets are mc-<app>--<name>.
App string
// contains filtered or unexported fields
}
Client is an S3 client for one app's buckets.
func New ¶
New makes a client from the app's maxcloud-s3 Secret (the AWS_* variables its functions get).
func (*Client) Download ¶
Download writes the object at key to a local file (through a temporary file next to it, so a failed download leaves nothing half-written), or to w if file is "".
func (*Client) List ¶
func (c *Client) List(ctx context.Context, name, prefix string, recursive bool, fn func(Object) error) error
List calls fn for every object under prefix in the bucket, in key order. Without recursive it stops at the next "/": deeper keys come once, as a folder (an Object whose Key ends in "/", with no size).
type Ref ¶
type Ref struct {
Bucket, Key string
}
Ref is a bucket and a key (or key prefix) in it: "uploads:img/a.png".
func ParseRef ¶
ParseRef splits BUCKET:KEY. ok is false for anything that isn't a bucket reference: a local path. A bucket's name is lowercase letters, digits and dashes, so "./a:b", "C:\x" and "/tmp/a:b" stay local.