s3

package
v0.0.0-...-378618d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2011 License: BSD-3-Clause, GooglePatentClause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USWEST_HOST      = "us-west-1.s3.amazonaws.com"
	USEAST_HOST      = "s3.amazonaws.com"
	APSOUTHEAST_HOST = "ap-southeast-1.s3.amazonaws.com"
	EUWEST_HOST      = "eu-west-1.s3.amazonaws.com"
)

Do S3 endpoints actually play any role?

View Source
const (
	DEFAULT_HASH = crypto.SHA1
)

Variables

This section is empty.

Functions

func VhostName

func VhostName(b string, ep *http.URL) string

Returns the vhost name of the bucket (bucket.s3.amazonaws.com)

Types

type Bucket

type Bucket struct {
	Name string
	URL  *http.URL
	// contains filtered or unexported fields
}

Represents a URL and connection to an S3 bucket.

func NewBucket

func NewBucket(u *http.URL, Name string, conn *aws.Conn) (b *Bucket)

NewBucket creates a new *Bucket object from an endpoint URL.

URL is the _endpoint_ url (nil will default to https://s3.amazonaws.com/) Name should be the bucket name; If you pass this as an empty string, you will regret it. conn is OPTIONAL, but allows you to re-use another aws.Conn if you'd like.

If you omit conn, the dialer used will be based off the VHost of your bucket (if possible), to ensure best performance (e.g., endpoint associated w/ your bucket, and any regional lb's)

func (*Bucket) Close

func (self *Bucket) Close() (err os.Error)

Closes the underlying connection

func (*Bucket) Delete

func (self *Bucket) Delete(id *aws.Signer, key string) (err os.Error)

Deletes the named key from the bucket. To delete a bucket, see *Service.DeleteBucket()

func (*Bucket) Exists

func (self *Bucket) Exists(id *aws.Signer, key string) (err os.Error)

Performs a HEAD request on the bucket and returns nil of the key appears valid (returns 200).

func (*Bucket) GetKey

func (self *Bucket) GetKey(id *aws.Signer, key string, w io.Writer) (hdr http.Header, err os.Error)

Opens the named key and copys it to the named io.Writer IFF the response.Status is 200. Also returns the http headers for convenience (regardless of status code, as long as a resp is generated).

func (*Bucket) HeadKey

func (self *Bucket) HeadKey(id *aws.Signer, key string) (resp *http.Response, err os.Error)

Performs a HEAD request on the bucket and returns the response object. The body is CLOSED, and it is an error to try and read from it.

func (*Bucket) ListKeys

func (self *Bucket) ListKeys(id *aws.Signer,
	prefix, delim, marker string, out chan<- string) (err os.Error)

Walks a bucket and writes the resulting strings to the channel. * There is currently NO (correct) way to abort a running walk.

func (*Bucket) PutFile

func (self *Bucket) PutFile(id *aws.Signer, key string, fp *os.File) (err os.Error)

Will put an open file descriptor to the named key. Size is determined by statting the fd (so a partially read file will not work). TODO: ACL's & content-type/headers support

func (*Bucket) PutKeyBytes

func (self *Bucket) PutKeyBytes(id *aws.Signer, key string, buff []byte, hdr http.Header) (err os.Error)

func (*Bucket) PutKeyReader

func (self *Bucket) PutKeyReader(id *aws.Signer, key string, r io.Reader, l int64, hdr http.Header) (err os.Error)

NB: Length is required as we do not buffer the reader NB(2): We do NOT close your reader (hence the io.Reader), we wrap it with a NopCloser.

func (*Bucket) PutLocalFile

func (self *Bucket) PutLocalFile(id *aws.Signer, key, file string) (err os.Error)

Will open a local file, size it, and upload it to the named key. This is a convenience wrapper aroudn PutFile.

type Service

type Service struct {
	URL *http.URL
	// contains filtered or unexported fields
}

func NewService

func NewService(url *http.URL) (s *Service)

Initilalize a new Service object with a specific S3 endpoint. If URL is omitted, it defaults to the us-east endpoint over HTTPS (https://s3.amazonaws.com/)

func (*Service) Bucket

func (self *Service) Bucket(name string) *Bucket

Returns a new *Bucket with the same URL data as the Service connection. You MUST have already created the bucket in order to make use of the Bucket object.

See CreateBucket to create a new bucket.

func (*Service) Close

func (self *Service) Close() (err os.Error)

Closes the underlying connection

func (*Service) CreateBucket

func (self *Service) CreateBucket(id *aws.Signer, name string) (err os.Error)

Creates a new bucket TODO: Will (probably) create the bucket in US-east no matter what underlying endpoint you've chosen.

func (*Service) DeleteBucket

func (self *Service) DeleteBucket(id *aws.Signer, name string) (err os.Error)

Deletes the named bucket from the S3 service.

func (*Service) ListBuckets

func (self *Service) ListBuckets(id *aws.Signer) (out []string, err os.Error)

Returns a list of bucket names known by the endpoint. Depending on the endpoint used, your list may be global or regional in nature.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL