diff --git a/upload/upload.go b/upload/upload.go index eafca1c..5c9cd8d 100644 --- a/upload/upload.go +++ b/upload/upload.go @@ -23,6 +23,16 @@ import ( "golang.org/x/image/font/inconsolata" ) +type State int + +const ( + Pending = iota + Queued + Uploading + Complete + Failed +) + type HTTPClient interface { Do(req *http.Request) (*http.Response, error) } diff --git a/upload/upload_test.go b/upload/upload_test.go index 46c9fc4..3996ff3 100644 --- a/upload/upload_test.go +++ b/upload/upload_test.go @@ -2,7 +2,11 @@ package upload import ( "bytes" + "image" + "image/color" + "image/png" "io/ioutil" + "math/rand" "net/http" "os" "testing" @@ -70,3 +74,28 @@ func TestTooBigUpload(t *testing.T) { t.Error("upload should have been marked failed") } } + +func tempImageGt8Mb() { + // about 12Mb + width := 2000 + height := 2000 + + upLeft := image.Point{0, 0} + lowRight := image.Point{width, height} + + img := image.NewRGBA(image.Rectangle{upLeft, lowRight}) + + // Colors are defined by Red, Green, Blue, Alpha uint8 values. + + // Set color for each pixel. + for x := 0; x < width; x++ { + for y := 0; y < height; y++ { + color := color.RGBA{uint8(rand.Int31n(256)), uint8(rand.Int31n(256)), uint8(rand.Int31n(256)), 0xff} + img.Set(x, y, color) + } + } + + // Encode as PNG. + f, _ := os.Create("image.png") + png.Encode(f, img) +}