Documentation ¶
Index ¶
- Constants
- type ACL
- type AccessControlList
- type AccessControlListGrants
- type AclOwner
- type Bucket
- func (b *Bucket) Del(path string) error
- func (b *Bucket) DelBucket() (err error)
- func (b *Bucket) DelMulti(objects Delete) error
- func (b *Bucket) DeleteLifecycleConfiguration() error
- func (b *Bucket) Exists(path string) (exists bool, err error)
- func (b *Bucket) Get(path string) (data []byte, err error)
- func (b *Bucket) GetACL(key string) (*AccessControlList, error)
- func (b *Bucket) GetLifecycleConfiguration() (*LifecycleConfiguration, error)
- func (b *Bucket) GetReader(path string) (rc io.ReadCloser, err error)
- func (b *Bucket) GetReaderWithHeaders(path string) (rc io.ReadCloser, header http.Header, err error)
- func (b *Bucket) GetResponse(path string) (resp *http.Response, err error)
- func (b *Bucket) GetResponseWithHeaders(path string, headers map[string][]string) (resp *http.Response, err error)
- func (b *Bucket) GetWithHeaders(path string) (data []byte, header http.Header, err error)
- func (b *Bucket) Head(path string, headers map[string][]string) (*http.Response, error)
- func (b *Bucket) InitMulti(key string, contType string, perm ACL, options Options) (*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) Location() (string, error)
- func (b *Bucket) Multi(key, contType string, perm ACL, options Options) (*Multi, error)
- func (b *Bucket) PostFormArgs(path string, expires time.Time, redirect string) (action string, fields map[string]string)
- func (b *Bucket) PostFormArgsEx(path string, expires time.Time, redirect string, conds []string) (action string, fields map[string]string)
- func (b *Bucket) Put(path string, data []byte, contType string, perm ACL, options Options) error
- func (b *Bucket) PutBucket(perm ACL) error
- func (b *Bucket) PutBucketSubresource(subresource string, r io.Reader, length int64) error
- func (b *Bucket) PutBucketWebsite(configuration WebsiteConfiguration) error
- func (b *Bucket) PutCopy(path string, perm ACL, options CopyOptions, source string) (*CopyObjectResult, error)
- func (b *Bucket) PutLifecycleConfiguration(c *LifecycleConfiguration) 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) SignedURLWithArgs(path string, expires time.Time, params url.Values, headers http.Header) string
- func (b *Bucket) SignedURLWithMethod(method, path string, expires time.Time, params url.Values, headers http.Header) string
- func (b *Bucket) URL(path string) string
- func (b *Bucket) UploadSignedURL(name, method, content_type string, expires time.Time) string
- func (b *Bucket) Versions(prefix, delim, keyMarker string, versionIdMarker string, max int) (result *VersionsResp, err error)
- type BucketInfo
- type CopyObjectResult
- type CopyOptions
- type Delete
- type Error
- type ErrorDocument
- type Expiration
- type GetLocationResp
- type GetServiceResp
- type Grant
- type Grantee
- type IndexDocument
- type Key
- type LifecycleConfiguration
- type LifecycleRule
- func (r *LifecycleRule) Disable()
- func (r *LifecycleRule) Enable()
- func (r *LifecycleRule) SetExpirationDate(date time.Time)
- func (r *LifecycleRule) SetExpirationDays(days uint)
- func (r *LifecycleRule) SetNoncurrentVersionExpirationDays(days uint)
- func (r *LifecycleRule) SetNoncurrentVersionTransitionDays(days uint)
- func (r *LifecycleRule) SetTransitionDate(date time.Time)
- func (r *LifecycleRule) SetTransitionDays(days uint)
- type ListResp
- type Multi
- func (m *Multi) Abort() error
- func (m *Multi) Complete(parts []Part) error
- func (m *Multi) ListParts() ([]Part, error)
- func (m *Multi) ListPartsFull(partNumberMarker int, maxParts int) ([]Part, error)
- func (m *Multi) PutAll(r ReaderAtSeeker, partSize int64) ([]Part, error)
- func (m *Multi) PutPart(n int, r io.ReadSeeker) (Part, error)
- func (m *Multi) PutPartCopy(n int, options CopyOptions, source string) (*CopyObjectResult, Part, error)
- type NoncurrentVersionExpiration
- type NoncurrentVersionTransition
- type Object
- type Options
- type Owner
- type Part
- type ReaderAtSeeker
- type RedirectAllRequestsTo
- type RoutingRule
- type S3
- type ServerSideEncryption
- type StorageClass
- type Transition
- type Version
- type VersionsResp
- type WebsiteConfiguration
Constants ¶
const ( LifecycleRuleStatusEnabled = "Enabled" LifecycleRuleStatusDisabled = "Disabled" LifecycleRuleDateFormat = "2006-01-02" StorageClassGlacier = "GLACIER" )
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 ( ReducedRedundancy = StorageClass("REDUCED_REDUNDANCY") StandardStorage = StorageClass("STANDARD") )
const ( S3Managed = ServerSideEncryption("AES256") KMSManaged = ServerSideEncryption("aws:kms") )
const AllUsersUri = "http://acs.amazonaws.com/groups/global/AllUsers"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ACL ¶
type ACL string
func GetCannedPolicyByAcl ¶
func GetCannedPolicyByAcl(acl AccessControlList) ACL
type AccessControlList ¶
type AccessControlList struct { Owner AclOwner Grants AccessControlListGrants }
func ParseAclFromXml ¶
func ParseAclFromXml(aclxml string) (AccessControlList, error)
type AccessControlListGrants ¶
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) DelMulti ¶
DelMulti removes up to 1000 objects from the S3 bucket.
See http://goo.gl/jx6cWK for details.
func (*Bucket) DeleteLifecycleConfiguration ¶
Delete the bucket's lifecycle configuration.
func (*Bucket) Exists ¶
Exists checks whether or not an object exists on an S3 bucket using a HEAD request.
func (*Bucket) Get ¶
Get retrieves an object from an S3 bucket.
See http://goo.gl/isCO7 for details.
func (*Bucket) GetACL ¶
func (b *Bucket) GetACL(key string) (*AccessControlList, error)
GetACL for getting ACL from bucket or object
func (*Bucket) GetLifecycleConfiguration ¶
func (b *Bucket) GetLifecycleConfiguration() (*LifecycleConfiguration, error)
Retrieves the lifecycle configuration for the bucket. AWS returns an error if no lifecycle found.
func (*Bucket) GetReader ¶
func (b *Bucket) GetReader(path string) (rc io.ReadCloser, err error)
GetReader retrieves an object from an S3 bucket, returning the body of the HTTP response. It is the caller's responsibility to call Close on rc when finished reading.
func (*Bucket) GetReaderWithHeaders ¶
func (b *Bucket) GetReaderWithHeaders(path string) (rc io.ReadCloser, header http.Header, err error)
GetReaderWithHeaders retrieves an object with headers from an S3 bucket
func (*Bucket) GetResponse ¶
GetResponse retrieves an object from an S3 bucket, returning the HTTP response. It is the caller's responsibility to call Close on rc when finished reading
func (*Bucket) GetResponseWithHeaders ¶
func (b *Bucket) GetResponseWithHeaders(path string, headers map[string][]string) (resp *http.Response, err error)
GetReaderWithHeaders retrieves an object from an S3 bucket Accepts custom headers to be sent as the second parameter returning the body of the HTTP response. It is the caller's responsibility to call Close on rc when finished reading
func (*Bucket) GetWithHeaders ¶
GetWithHeaders retrieves an object with headers from an S3 bucket.
func (*Bucket) Head ¶
Head HEADs an object in the S3 bucket, returns the response with no body see http://bit.ly/17K1ylI
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) PostFormArgs ¶
func (b *Bucket) PostFormArgs(path string, expires time.Time, redirect string) (action string, fields map[string]string)
PostFormArgs returns the action and input fields needed to allow anonymous uploads to a bucket within the expiration limit
func (*Bucket) PostFormArgsEx ¶
func (b *Bucket) PostFormArgsEx(path string, expires time.Time, redirect string, conds []string) (action string, fields map[string]string)
PostFormArgs returns the action and input fields needed to allow anonymous uploads to a bucket within the expiration limit Additional conditions can be specified with conds
func (*Bucket) PutBucketSubresource ¶
func (*Bucket) PutBucketWebsite ¶
func (b *Bucket) PutBucketWebsite(configuration WebsiteConfiguration) error
PutBucketWebsite configures a bucket as a website.
See http://goo.gl/TpRlUy for details.
func (*Bucket) PutCopy ¶
func (b *Bucket) PutCopy(path string, perm ACL, options CopyOptions, source string) (*CopyObjectResult, error)
PutCopy puts a copy of an object given by the key path into bucket b using b.Path as the target key
func (*Bucket) PutLifecycleConfiguration ¶
func (b *Bucket) PutLifecycleConfiguration(c *LifecycleConfiguration) error
Sets the bucket's lifecycle configuration.
func (*Bucket) PutReader ¶
func (b *Bucket) PutReader(path string, r io.Reader, length int64, contType string, perm ACL, options Options) error
PutReader inserts an object into the S3 bucket by consuming data from r until EOF.
func (*Bucket) SignedURL ¶
SignedURL returns a signed URL that allows anyone holding the URL to retrieve the object at path. The signature is valid until expires.
func (*Bucket) SignedURLWithArgs ¶
func (b *Bucket) SignedURLWithArgs(path string, expires time.Time, params url.Values, headers http.Header) string
SignedURLWithArgs returns a signed URL that allows anyone holding the URL to retrieve the object at path. The signature is valid until expires.
func (*Bucket) SignedURLWithMethod ¶
func (b *Bucket) SignedURLWithMethod(method, path string, expires time.Time, params url.Values, headers http.Header) string
SignedURLWithMethod returns a signed URL that allows anyone holding the URL to either retrieve the object at path or make a HEAD request against it. The signature is valid until expires.
func (*Bucket) URL ¶
URL returns a non-signed URL that allows retriving the object at path. It only works if the object is publicly readable (see SignedURL).
func (*Bucket) UploadSignedURL ¶
UploadSignedURL returns a signed URL that allows anyone holding the URL to upload the object at path. The signature is valid until expires. contenttype is a string like image/png name is the resource name in s3 terminology like images/ali.png [obviously excluding the bucket name itself]
type BucketInfo ¶
type CopyObjectResult ¶
CopyObjectResult is the output from a Copy request
type CopyOptions ¶
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 ErrorDocument ¶
type ErrorDocument struct {
Key string `xml:"Key"`
}
type Expiration ¶
type GetLocationResp ¶
type GetLocationResp struct {
Location string `xml:",innerxml"`
}
type GetServiceResp ¶
type GetServiceResp struct { Owner Owner Buckets []BucketInfo `xml:">Bucket"` }
type IndexDocument ¶
type IndexDocument struct {
Suffix string `xml:"Suffix"`
}
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 LifecycleConfiguration ¶
type LifecycleConfiguration struct { XMLName xml.Name `xml:"LifecycleConfiguration"` Rules *[]*LifecycleRule `xml:"Rule,omitempty"` }
func (*LifecycleConfiguration) AddRule ¶
func (c *LifecycleConfiguration) AddRule(r *LifecycleRule)
Adds a LifecycleRule to the configuration.
type LifecycleRule ¶
type LifecycleRule struct { ID string `xml:"ID"` Prefix string `xml:"Prefix"` Status string `xml:"Status"` NoncurrentVersionTransition *NoncurrentVersionTransition `xml:"NoncurrentVersionTransition,omitempty"` NoncurrentVersionExpiration *NoncurrentVersionExpiration `xml:"NoncurrentVersionExpiration,omitempty"` Transition *Transition `xml:"Transition,omitempty"` Expiration *Expiration `xml:"Expiration,omitempty"` }
func NewLifecycleRule ¶
func NewLifecycleRule(id, prefix string) *LifecycleRule
Create a lifecycle rule with arbitrary identifier id and object name prefix for which the rules should apply.
func (*LifecycleRule) Enable ¶
func (r *LifecycleRule) Enable()
Marks the rule as enabled (default).
func (*LifecycleRule) SetExpirationDate ¶
func (r *LifecycleRule) SetExpirationDate(date time.Time)
Adds an expiration rule as a date. Overwrites any previous expiration rule.
func (*LifecycleRule) SetExpirationDays ¶
func (r *LifecycleRule) SetExpirationDays(days uint)
Adds an expiration rule in days. Overwrites any previous expiration rule. Days must be > 0.
func (*LifecycleRule) SetNoncurrentVersionExpirationDays ¶
func (r *LifecycleRule) SetNoncurrentVersionExpirationDays(days uint)
Adds a noncurrent version expiration rule. Days must be > 0. Overwrites any previous noncurrent version expiration rule.
func (*LifecycleRule) SetNoncurrentVersionTransitionDays ¶
func (r *LifecycleRule) SetNoncurrentVersionTransitionDays(days uint)
Adds a noncurrent version transition rule. Overwrites any previous noncurrent version transition rule.
func (*LifecycleRule) SetTransitionDate ¶
func (r *LifecycleRule) SetTransitionDate(date time.Time)
Adds a transition rule as a date. Overwrites any previous transition rule.
func (*LifecycleRule) SetTransitionDays ¶
func (r *LifecycleRule) SetTransitionDays(days uint)
Adds a transition rule in days. Overwrites any previous transition rule.
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"` // if IsTruncated is true, pass NextMarker as marker argument to List() // to get the next set of keys NextMarker string }
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) ListPartsFull ¶
ListParts returns the list of previously uploaded parts in m, ordered by part number (Only parts with higher part numbers than partNumberMarker will be listed). Only up to maxParts parts will be returned.
See http://goo.gl/ePioY for details.
func (*Multi) PutAll ¶
func (m *Multi) PutAll(r ReaderAtSeeker, partSize int64) ([]Part, error)
PutAll sends all of r via a multipart upload with parts no larger than partSize bytes, which must be set to at least 5MB. Parts previously uploaded are either reused if their checksum and size match the new part, or otherwise overwritten with the new content. PutAll returns all the parts of m (reused or not).
func (*Multi) PutPart ¶
PutPart sends part n of the multipart upload, reading all the content from r. Each part, except for the last one, must be at least 5MB in size.
See http://goo.gl/pqZer for details.
func (*Multi) PutPartCopy ¶
func (m *Multi) PutPartCopy(n int, options CopyOptions, source string) (*CopyObjectResult, Part, error)
type NoncurrentVersionExpiration ¶
type NoncurrentVersionExpiration struct {
Days *uint `xml:"NoncurrentDays,omitempty"`
}
type Options ¶
type Options struct { SSE bool SSEKMS bool SSEKMSKeyId string SSECustomerAlgorithm string SSECustomerKey string SSECustomerKeyMD5 string Meta map[string][]string ContentEncoding string CacheControl string RedirectLocation string ContentMD5 string ContentDisposition string Range string StorageClass StorageClass }
Fold options into an Options struct
type ReaderAtSeeker ¶
type ReaderAtSeeker interface { io.ReaderAt io.ReadSeeker }
type RedirectAllRequestsTo ¶
type RoutingRule ¶
type S3 ¶
type S3 struct { aws.Auth aws.Region ConnectTimeout time.Duration ReadTimeout time.Duration Signature int // contains filtered or unexported fields }
The S3 type encapsulates operations with an S3 region.
func (*S3) GetService ¶
func (s3 *S3) GetService() (*GetServiceResp, error)
GetService gets a list of all buckets owned by an account.
See http://goo.gl/wbHkGj for details.
type ServerSideEncryption ¶
type ServerSideEncryption string
type StorageClass ¶
type StorageClass string
type Transition ¶
type Version ¶
type Version struct { Key string VersionId string IsLatest bool LastModified string // ETag gives the hex-encoded MD5 sum of the contents, // surrounded with double-quotes. ETag string Size int64 Owner Owner StorageClass string }
The Version type represents an object version stored in an S3 bucket.
type VersionsResp ¶
type VersionsResp struct { Name string Prefix string KeyMarker string VersionIdMarker string MaxKeys int Delimiter string IsTruncated bool Versions []Version `xml:"Version"` CommonPrefixes []string `xml:">Prefix"` }
The VersionsResp type holds the results of a list bucket Versions operation.
type WebsiteConfiguration ¶
type WebsiteConfiguration struct { XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ WebsiteConfiguration"` IndexDocument *IndexDocument `xml:"IndexDocument,omitempty"` ErrorDocument *ErrorDocument `xml:"ErrorDocument,omitempty"` RoutingRules *[]RoutingRule `xml:"RoutingRules>RoutingRule,omitempty"` RedirectAllRequestsTo *RedirectAllRequestsTo `xml:"RedirectAllRequestsTo,omitempty"` }