Documentation
¶
Index ¶
- Variables
- func Create(uri string, h http.Header, c *http.Client) (io.WriteCloser, error)
- func Get(url string) (resp *http.Response, err error)
- func Head(url string) (resp *http.Response, err error)
- func Open(uri string, c *http.Client) (io.ReadCloser, http.Header, error)
- func Post(url string, contentType string, body io.Reader) (resp *http.Response, err error)
- func PostForm(url string, data url.Values) (resp *http.Response, err error)
- func Remove(uri string, c *http.Client) error
- func Walk(uri string, walkFn WalkFunc, client *http.Client) error
- type Object
- type WalkFunc
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultClient = &http.Client{ Transport: DefaultSigner.Transport(), }
DefaultClient is the default http.Client used for all requests.
View Source
var DefaultSigner = &aws.V4Signer{ Region: os.Getenv("AWS_REGION"), AccessKey: os.Getenv("AWS_ACCESS_KEY_ID"), SecretKey: os.Getenv("AWS_SECRET_ACCESS_KEY"), SecurityToken: os.Getenv("AWS_SECURITY_TOKEN"), Service: "s3", }
DefaultSigner is the default Signer and is use for all requests.
View Source
var SkipDir = errors.New("skip this directory")
SkipDir is used as a return value from WalkFuncs to indicate that the directory named in the call is to be skipped. It is not returned as an error by any function.
Functions ¶
func Create ¶
Create creates an S3 object at url and sends multipart upload requests as data is written.
Example ¶
f, _ := os.Open("file.txt") w, err := Create("s3://s3-us-west-2.amazonaws.com/bucket_name/file.txt", nil, nil) if err != nil { return } io.Copy(w, f)
Output:
func Open ¶
Open opens an S3 object at url and return a io.ReadCloser.
Example ¶
r, _, err := Open("s3://s3-us-west-2.amazonaws.com/bucket_name/file.txt", nil) if err != nil { return } f, _ := os.Open("file.txt") io.Copy(f, r)
Output:
func PostForm ¶
PostForm issues a POST to the specified URL, with data's keys and values URL-encoded as the request body.
func Remove ¶
Remove removes the given object.
Example ¶
if err := Remove("s3://s3-us-west-2.amazonaws.com/bucket_name/object.txt", nil); err != nil { return }
Output:
func Walk ¶
Walk walks the bucket starting at prefix, calling walkFn for each objects in the bucket.
Example ¶
walkFn := func(name string, info os.FileInfo) error { if info.IsDir() { return SkipDir } return nil } if err := Walk("s3://s3-us-west-2.amazonaws.com/bucket_name/", walkFn, nil); err != nil { return }
Output:
Types ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.