Add new function to generate files that can be resized. Add states for upcoming queue changes.
This commit is contained in:
parent
71c70ce965
commit
6fa6c34ccb
@ -23,6 +23,16 @@ import (
|
|||||||
"golang.org/x/image/font/inconsolata"
|
"golang.org/x/image/font/inconsolata"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type State int
|
||||||
|
|
||||||
|
const (
|
||||||
|
Pending = iota
|
||||||
|
Queued
|
||||||
|
Uploading
|
||||||
|
Complete
|
||||||
|
Failed
|
||||||
|
)
|
||||||
|
|
||||||
type HTTPClient interface {
|
type HTTPClient interface {
|
||||||
Do(req *http.Request) (*http.Response, error)
|
Do(req *http.Request) (*http.Response, error)
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,11 @@ package upload
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"image"
|
||||||
|
"image/color"
|
||||||
|
"image/png"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
@ -70,3 +74,28 @@ func TestTooBigUpload(t *testing.T) {
|
|||||||
t.Error("upload should have been marked failed")
|
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)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user