summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandomChars <random@chars.jp>2021-10-03 23:31:14 +0900
committerRandomChars <random@chars.jp>2021-10-03 23:31:14 +0900
commit404e0dffdf4f4406d33164348f3374b48f8a1d14 (patch)
tree4a6e487357be3c8dc036bd9a357c7d17a200f6de
parentdb9cc3c488718596342520719b61322e63474850 (diff)
fix error returns on API, fix form file uploadv1.3.5
-rw-r--r--api.go6
-rw-r--r--client/image.go2
2 files changed, 4 insertions, 4 deletions
diff --git a/api.go b/api.go
index 3134acf..05d4d74 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 51f70d6..6fcd8ed 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 {