Documentation ¶
Overview ¶
Package s3util provides streaming transfers to and from Amazon S3.
To use it, open or create an S3 object, read or write data, and close the object.
You must assign valid credentials to DefaultConfig.Keys before using DefaultConfig. Be sure to close an io.WriteCloser returned by this package, to flush buffers and complete the multipart upload process.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = &Config{ Service: s3.DefaultService, Keys: new(s3.Keys), }
Functions ¶
func Create ¶
Create creates an S3 object at url and sends multipart upload requests as data is written.
If h is not nil, each of its entries is added to the HTTP request header. If c is nil, Create uses DefaultConfig.
Example ¶
package main import ( "github.com/kr/s3/s3util" "io" "os" ) func main() { s3util.DefaultConfig.AccessKey = "...access key..." s3util.DefaultConfig.SecretKey = "...secret key..." r, _ := os.Open("/dev/stdin") w, _ := s3util.Create("https://mybucket.s3.amazonaws.com/log.txt", nil, nil) io.Copy(w, r) w.Close() }
Output:
func Open ¶
func Open(url string, c *Config) (io.ReadCloser, error)
Open requests the S3 object at url. An HTTP status other than 200 is considered an error.
If c is nil, Open uses DefaultConfig.
Example ¶
package main import ( "github.com/kr/s3/s3util" "io" "os" ) func main() { s3util.DefaultConfig.AccessKey = "...access key..." s3util.DefaultConfig.SecretKey = "...secret key..." r, _ := s3util.Open("https://mybucket.s3.amazonaws.com/log.txt", nil) w, _ := os.Create("out.txt") io.Copy(w, r) w.Close() }
Output: