diff --git a/api.go b/api.go index 3134acf1b178599b7e452f7132acc79ed9345efb..05d4d740a3e7c7d4a7ea7fa612890e01ca2b8f90 100644 --- a/api.go +++ b/api.go @@ -300,19 +300,19 @@ func registerAPI() { payload, err := context.FormFile("image") if err != nil { - context.JSON(http.StatusInternalServerError, err) + context.JSON(http.StatusInternalServerError, api.Error{Error: err.Error()}) return } file, err := payload.Open() if err != nil { log.Errorf("Error while opening uploaded file %s, %s", payload.Filename, err) - context.JSON(http.StatusInternalServerError, err) + context.JSON(http.StatusInternalServerError, api.Error{Error: err.Error()}) return } data, err := ioutil.ReadAll(file) if err != nil { log.Errorf("Error while reading uploaded file %s, %s", payload.Filename, err) - context.JSON(http.StatusInternalServerError, err) + context.JSON(http.StatusInternalServerError, api.Error{Error: err.Error()}) return } image := instance.ImageAdd(data, info.Snowflake) diff --git a/client/image.go b/client/image.go index 51f70d6139390bd634ec60db6f639b22456f5d8b..6fcd8ed1ad7969e3f33b4abf191e30b93ab0a6f4 100644 --- a/client/image.go +++ b/client/image.go @@ -30,7 +30,7 @@ func (r *Remote) ImageAdd(reader io.Reader) (store.Image, error) { buf := &bytes.Buffer{} w := multipart.NewWriter(buf) - if f, err := w.CreateFormField("image"); err != nil { + if f, err := w.CreateFormFile("image", "image"); err != nil { return store.Image{}, err } else { if _, err = io.Copy(f, reader); err != nil {