Documentation ¶
Index ¶
- Constants
- Variables
- func HMAC(key, data []byte) []byte
- func MD5B64(in []byte) string
- func RetryAttempts(retry bool)
- func SHA256Hex(in []byte) string
- func Sign(auth aws.Auth, method, canonicalPath string, ...)
- type ACL
- type Bucket
- func (b *Bucket) Del(path string) error
- func (b *Bucket) DelBucket() (err error)
- func (b *Bucket) Get(path string) (data []byte, err error)
- func (b *Bucket) GetInfoRangeReader(path string, r *ObjectRange) (key *Key, rc io.ReadCloser, err error)
- func (b *Bucket) GetReader(path string) (rc io.ReadCloser, err error)
- func (b *Bucket) Info(path string) (key *Key, err error)
- func (b *Bucket) InitMulti(key string, contType string, perm ACL) (*Multi, error)
- func (b *Bucket) List(prefix, delim, marker string, max int) (result *ListResp, err error)
- func (b *Bucket) ListMulti(prefix, delim string) (multis []*Multi, prefixes []string, err error)
- func (b *Bucket) Multi(key, contType string, perm ACL) (*Multi, error)
- func (b *Bucket) Put(path string, data []byte, contType string, perm ACL) error
- func (b *Bucket) PutBucket(perm ACL) error
- func (b *Bucket) PutReader(path string, r io.Reader, length int64, contType string, perm ACL, ...) error
- func (b *Bucket) SignedURL(path string, expires time.Time) string
- func (b *Bucket) URL(path string) string
- type Error
- type Key
- type ListResp
- type Multi
- type ObjectRange
- type Owner
- type Part
- type ReaderAtSeeker
- type S3
- type V4Signer
Constants ¶
const ( Private = ACL("private") PublicRead = ACL("public-read") PublicReadWrite = ACL("public-read-write") AuthenticatedRead = ACL("authenticated-read") BucketOwnerRead = ACL("bucket-owner-read") BucketOwnerFull = ACL("bucket-owner-full-control") )
const ( ISO8601BasicFormat = "20060102T150405Z" ISO8601BasicFormatShort = "20060102" )
Common date formats for signing requests
Variables ¶
var EmptyStringSHA256Hex = SHA256Hex(nil)
Functions ¶
func RetryAttempts ¶
func RetryAttempts(retry bool)
RetryAttempts sets whether failing S3 requests may be retried to cope with eventual consistency or temporary failures. It should not be called while operations are in progress.
Types ¶
type Bucket ¶
The Bucket type encapsulates operations with an S3 bucket.
func (*Bucket) DelBucket ¶
DelBucket removes an existing S3 bucket. All objects in the bucket must be removed before the bucket itself can be removed.
See http://goo.gl/GoBrY for details.
func (*Bucket) Get ¶
Get retrieves an object from an S3 bucket.
See http://goo.gl/isCO7 for details.
func (*Bucket) GetInfoRangeReader ¶
func (b *Bucket) GetInfoRangeReader(path string, r *ObjectRange) (key *Key, rc io.ReadCloser, err error)
GetReader retrieves an object info and range from an S3 bucket. ObjectRange parameter can be nil. It is the caller's responsibility to call Close on rc when finished reading.
func (*Bucket) GetReader ¶
func (b *Bucket) GetReader(path string) (rc io.ReadCloser, err error)
GetReader retrieves an object from an S3 bucket. It is the caller's responsibility to call Close on rc when finished reading.
func (*Bucket) Info ¶
Info retrieves an object info from an S3 bucket. Failing S3 requests will not be retried
func (*Bucket) InitMulti ¶
InitMulti initializes a new multipart upload at the provided key inside b and returns a value for manipulating it.
See http://goo.gl/XP8kL for details.
func (*Bucket) List ¶
List returns information about objects in an S3 bucket.
The prefix parameter limits the response to keys that begin with the specified prefix.
The delim parameter causes the response to group all of the keys that share a common prefix up to the next delimiter in a single entry within the CommonPrefixes field. You can use delimiters to separate a bucket into different groupings of keys, similar to how folders would work.
The marker parameter specifies the key to start with when listing objects in a bucket. Amazon S3 lists objects in alphabetical order and will return keys alphabetically greater than the marker.
The max parameter specifies how many keys + common prefixes to return in the response. The default is 1000.
For example, given these keys in a bucket:
index.html index2.html photos/2006/January/sample.jpg photos/2006/February/sample2.jpg photos/2006/February/sample3.jpg photos/2006/February/sample4.jpg
Listing this bucket with delimiter set to "/" would yield the following result:
&ListResp{ Name: "sample-bucket", MaxKeys: 1000, Delimiter: "/", Contents: []Key{ {Key: "index.html", "index2.html"}, }, CommonPrefixes: []string{ "photos/", }, }
Listing the same bucket with delimiter set to "/" and prefix set to "photos/2006/" would yield the following result:
&ListResp{ Name: "sample-bucket", MaxKeys: 1000, Delimiter: "/", Prefix: "photos/2006/", CommonPrefixes: []string{ "photos/2006/February/", "photos/2006/January/", }, }
See http://goo.gl/YjQTc for details.
func (*Bucket) ListMulti ¶
ListMulti returns the list of unfinished multipart uploads in b.
The prefix parameter limits the response to keys that begin with the specified prefix. You can use prefixes to separate a bucket into different groupings of keys (to get the feeling of folders, for example).
The delim parameter causes the response to group all of the keys that share a common prefix up to the next delimiter in a single entry within the CommonPrefixes field. You can use delimiters to separate a bucket into different groupings of keys, similar to how folders would work.
See http://goo.gl/ePioY for details.
func (*Bucket) Multi ¶
Multi returns a multipart upload handler for the provided key inside b. If a multipart upload exists for key, it is returned, otherwise a new multipart upload is initiated with contType and perm.
func (*Bucket) PutReader ¶
func (b *Bucket) PutReader(path string, r io.Reader, length int64, contType string, perm ACL, md5b64 string, sha256hex string) error
PutReader inserts an object into the S3 bucket by consuming data from r until EOF.
type Error ¶
type Error struct { StatusCode int // HTTP status code (200, 403, ...) Code string // EC2 error code ("UnsupportedOperation", ...) Message string // The human-oriented error message BucketName string RequestId string HostId string }
Error represents an error in an operation with S3.
type Key ¶
type Key struct { Key string LastModified string Size int64 // ETag gives the hex-encoded MD5 sum of the contents, // surrounded with double-quotes. ETag string StorageClass string Owner Owner }
The Key type represents an item stored in an S3 bucket.
type ListResp ¶
type ListResp struct { Name string Prefix string Delimiter string Marker string MaxKeys int // IsTruncated is true if the results have been truncated because // there are more keys and prefixes than can fit in MaxKeys. // N.B. this is the opposite sense to that documented (incorrectly) in // http://goo.gl/YjQTc IsTruncated bool Contents []Key CommonPrefixes []string `xml:">Prefix"` }
The ListResp type holds the results of a List bucket operation.
type Multi ¶
Multi represents an unfinished multipart upload.
Multipart uploads allow sending big objects in smaller chunks. After all parts have been sent, the upload must be explicitly completed by calling Complete with the list of parts.
See http://goo.gl/vJfTG for an overview of multipart uploads.
func (*Multi) Abort ¶
Abort deletes an unifinished multipart upload and any previously uploaded parts for it.
After a multipart upload is aborted, no additional parts can be uploaded using it. However, if any part uploads are currently in progress, those part uploads might or might not succeed. As a result, it might be necessary to abort a given multipart upload multiple times in order to completely free all storage consumed by all parts.
NOTE: If the described scenario happens to you, please report back to the goamz authors with details. In the future such retrying should be handled internally, but it's not clear what happens precisely (Is an error returned? Is the issue completely undetectable?).
See http://goo.gl/dnyJw for details.
func (*Multi) Complete ¶
Complete assembles the given previously uploaded parts into the final object. This operation may take several minutes.
See http://goo.gl/2Z7Tw for details.
func (*Multi) ListParts ¶
ListParts returns the list of previously uploaded parts in m, ordered by part number.
See http://goo.gl/ePioY for details.
func (*Multi) PutPartHash ¶
func (m *Multi) PutPartHash(n int, r io.ReadSeeker, partSize int64, md5b64 string, sha256hex string) (Part, error)
PutPartHash sends part n of the multipart upload, reading all the content from r with partSize and MD5 base64 encoded hash. Each part, except for the last one, must be at least 5MB in size.
See http://goo.gl/pqZer for details.
type ObjectRange ¶
type ObjectRange struct {
Start, End int64
}
ObjectRange represents HTTP Range header
type ReaderAtSeeker ¶
type ReaderAtSeeker interface { io.ReaderAt io.ReadSeeker }
type V4Signer ¶
type V4Signer struct {
// contains filtered or unexported fields
}
The V4Signer encapsulates all of the functionality to sign a request with the AWS Signature Version 4 Signing Process. (http://goo.gl/u1OWZz)
func NewV4Signer ¶
Return a new instance of a V4Signer capable of signing AWS requests.
func (*V4Signer) Sign ¶
Sign a request according to the AWS Signature Version 4 Signing Process. (http://goo.gl/u1OWZz) The signed request will include an "x-amz-date" header with a current timestamp if a valid "x-amz-date" or "date" header was not available in the original request. In addition, AWS Signature Version 4 requires the "host" header to be a signed header, therefor the Sign method will manually set a "host" header from the request.Host. The signed request will include a new "Authorization" header indicating that the request has been signed. Any changes to the request after signing the request will invalidate the signature.