Index | Files

package s3

import ""

Package s3 implements a generic Amazon S3 client, not specific to Camlistore.


Package Files

auth.go client.go

func IsValidBucket Uses

func IsValidBucket(bucket string) bool

IsValid reports whether bucket is a valid bucket name, per Amazon's naming restrictions.


type Auth Uses

type Auth struct {
    AccessKey       string
    SecretAccessKey string

    // Hostname is the S3 hostname to use.
    // If empty, the standard US region of "" is
    // used.
    Hostname string

func (*Auth) SignRequest Uses

func (a *Auth) SignRequest(req *http.Request)

type Bucket Uses

type Bucket struct {
    Name         string
    CreationDate string // 2006-02-03T16:45:09.000Z

type Client Uses

type Client struct {
    Transport http.RoundTripper // or nil for the default
    // PutGate limits the number of concurrent PutObject calls, because
    // apparently S3 throttles us if there are too many. No limit if nil.
    // Default in S3 blobserver is 5.
    PutGate *syncutil.Gate
    NoSSL   bool // disable SSL. For testing against fake-s3.

Client is an Amazon S3 client.

func (*Client) BucketLocation Uses

func (c *Client) BucketLocation(bucket string) (location string, err error)

BucketLocation returns the S3 hostname to be used with the given bucket.

func (*Client) Buckets Uses

func (c *Client) Buckets() ([]*Bucket, error)

func (*Client) Delete Uses

func (c *Client) Delete(bucket, key string) error

func (*Client) Get Uses

func (c *Client) Get(bucket, key string) (body io.ReadCloser, size int64, err error)

func (*Client) GetPartial Uses

func (c *Client) GetPartial(bucket, key string, offset, length int64) (rc io.ReadCloser, err error)

GetPartial fetches part of the s3 key object in bucket. If length is negative, the rest of the object is returned. The caller must close rc.

func (*Client) ListBucket Uses

func (c *Client) ListBucket(bucket string, startAt string, maxKeys int) (items []*Item, err error)

ListBucket returns 0 to maxKeys (inclusive) items from the provided bucket. Keys before startAt will be skipped. (This is the S3 'marker' value). If the length of the returned items is equal to maxKeys, there is no indication whether or not the returned list is truncated.

func (*Client) PutObject Uses

func (c *Client) PutObject(key, bucket string, md5 hash.Hash, size int64, body io.Reader) error

func (*Client) Stat Uses

func (c *Client) Stat(key, bucket string) (size int64, reterr error)

Returns 0, os.ErrNotExist if not on S3, otherwise reterr is real.

type Error Uses

type Error struct {
    Op     string
    Code   int         // HTTP status code
    Body   []byte      // response body
    Header http.Header // response headers

    // UsedEndpoint and AmazonCode are the XML response's Endpoint and
    // Code fields, respectively.
    UseEndpoint string // if a temporary redirect (wrong hostname)
    AmazonCode  string

Error is the type returned by some API operations.

TODO: it should be more/all of them.

func (*Error) Error Uses

func (e *Error) Error() string

type Item Uses

type Item struct {
    Key  string
    Size int64

Package s3 imports 21 packages (graph) and is imported by 33 packages. Updated 2018-02-14. Refresh now. Tools for package owners.