package s3_test

import (
	"fmt"
	"github.com/kr/s3"
	"log"
	"net/http"
	"os"
	"strings"
	"time"
)

func ExampleSign() {
	keys := s3.Keys{
		os.Getenv("S3_ACCESS_KEY"),
		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)
}

package s3

import (
	"fmt"
	"log"
	"net/http"
	"os"
	"strings"
	"time"
)

func ExampleSign() {
	keys := Keys{
		os.Getenv("S3_ACCESS_KEY"),
		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")
	Sign(r, keys)
	resp, err := http.DefaultClient.Do(r)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(resp.StatusCode)
}

Put test in the same package as the implementation
Put test in the same package as the implementation

This avoids a reliance on github for mere testing when retrieving a
copy of the source.

Signed-off-by: Daniel Farina <3d0f3b9ddcacec30c4008c5e030e6c13a478cb4f@heroku.com>
