Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = &Config{ Concurrency: 10, PartSize: 20 * mb, NTry: 10, Md5Check: true, Scheme: "https", Client: ClientWithTimeout(clientTimeout), }
DefaultConfig contains defaults used if *Config is nil
var DefaultDomain = "s3.amazonaws.com"
DefaultDomain is set to the endpoint for the U.S. S3 service.
Functions ¶
func ClientWithTimeout ¶
ClientWithTimeout is an http client optimized for high throughput to S3, It times out more agressively than the default http client in net/http as well as setting deadlines on the TCP connection
Types ¶
type Bucket ¶
A Bucket for an S3 service.
func (*Bucket) GetReader ¶
GetReader provides a reader and downloads data using parallel ranged get requests. Data from the requests are ordered and written sequentially.
Data integrity is verified via the option specified in c. Header data from the downloaded object is also returned, useful for reading object metadata. DefaultConfig is used if c is nil
Example ¶
k, err := EnvKeys() // get S3 keys from environment if err != nil { return err } // Open bucket to put file into s3 := New("", k) b := s3.Bucket("bucketName") r, h, err := b.GetReader("keyName", nil) if err != nil { return err } // stream to standard output if _, err = io.Copy(os.Stdout, r); err != nil { return err } err = r.Close() if err != nil { return err } fmt.Println(h) // print key header data return nil
Output:
func (*Bucket) PutWriter ¶
PutWriter provides a writer to upload data as multipart upload requests.
Each header in h is added to the HTTP request header. This is useful for specifying options such as server-side encryption in metadata as well as custom user metadata. DefaultConfig is used if c is nil.
Example ¶
k, err := EnvKeys() // get S3 keys from environment if err != nil { return err } // Open bucket to put file into s3 := New("", k) b := s3.Bucket("bucketName") // open file to upload file, err := os.Open("fileName") if err != nil { return err } // Open a PutWriter for upload w, err := b.PutWriter(file.Name(), nil, nil) if err != nil { return err } if _, err = io.Copy(w, file); err != nil { // Copy into S3 return err } if err = w.Close(); err != nil { return err } return nil
Output:
type Config ¶
type Config struct { *http.Client // http client to use for requests Concurrency int // number of parts to get or put concurrently PartSize int64 // initial part size in bytes to use for multipart gets or puts NTry int // maximum attempts for each part Md5Check bool // The md5 hash of the object is stored in <bucket>/.md5/<object_key>.md5 // When true, it is stored on puts and verified on gets Scheme string // url scheme, defaults to 'https' }
Config includes configuration parameters for s3gof3r
type Keys ¶
Keys for an Amazon Web Services account. Used for signing http requests.
func InstanceKeys ¶ added in v0.3.2
InstanceKeys Requests the AWS keys from the instance-based metadata on EC2 Assumes only one IAM role.