.pixil files now encode width as a string :(
This commit is contained in:
parent
713f91a844
commit
fcfc2e0ad5
|
@ -1 +1,2 @@
|
||||||
cache/
|
cache/
|
||||||
|
wallart-server
|
||||||
|
|
|
@ -35,7 +35,12 @@ func handleUpload(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if pixil.Width != 8 || pixil.Height != 8 {
|
if err := pixil.Parse(); err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if pixil.width != 8 || pixil.height != 8 {
|
||||||
http.Error(w, "Invalid image size", http.StatusBadRequest)
|
http.Error(w, "Invalid image size", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -106,13 +111,13 @@ func handleUpload(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("New image successfully uploaded")
|
log.Println("New image successfully uploaded")
|
||||||
}
|
}
|
||||||
|
|
||||||
func logRequestHandler(h http.Handler) http.Handler {
|
func logRequestHandler(h http.Handler) http.Handler {
|
||||||
fn := func(w http.ResponseWriter, r *http.Request) {
|
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL)
|
log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL)
|
||||||
h.ServeHTTP(w, r)
|
h.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
return http.HandlerFunc(fn)
|
return http.HandlerFunc(fn)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,9 +12,23 @@ type PixilFrame struct {
|
||||||
Preview string `json:"preview"`
|
Preview string `json:"preview"`
|
||||||
}
|
}
|
||||||
type Pixil struct {
|
type Pixil struct {
|
||||||
Width uint `json:"width"`
|
width int
|
||||||
Height uint `json:"height"`
|
height int
|
||||||
Frames []PixilFrame `json:"frames"`
|
WidthString string `json:"width"`
|
||||||
|
HeightString string `json:"height"`
|
||||||
|
Frames []PixilFrame `json:"frames"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Pixil) Parse() error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
p.width, err = strconv.Atoi(p.WidthString)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
p.height, err = strconv.Atoi(p.HeightString)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (frame *PixilFrame) GetPreview() []byte {
|
func (frame *PixilFrame) GetPreview() []byte {
|
||||||
|
|
Loading…
Reference in New Issue