mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
This commit moves dependency management to use godep and the new experimental vendoring support in Go 1.5. NOTE: You must set `GO15VENDOREXPERIMENT` in your bash environment for vendoring to work properly! See the updated `README` for details.
30 lines
615 B
Go
30 lines
615 B
Go
package s3_test
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/kr/s3"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
func ExampleSign() {
|
|
keys := s3.Keys{
|
|
AccessKey: os.Getenv("S3_ACCESS_KEY"),
|
|
SecretKey: os.Getenv("S3_SECRET_KEY"),
|
|
}
|
|
data := strings.NewReader("hello, world")
|
|
r, _ := http.NewRequest("PUT", "https://example.s3.amazonaws.com/foo", data)
|
|
r.ContentLength = int64(data.Len())
|
|
r.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
|
|
r.Header.Set("X-Amz-Acl", "public-read")
|
|
s3.Sign(r, keys)
|
|
resp, err := http.DefaultClient.Do(r)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
fmt.Println(resp.StatusCode)
|
|
}
|