Use base64 to upload image

So you can use:
    base64 mangemoi.jpg | curl --data @- http://localhost:8080/api/images/mangemoi
This commit is contained in:
nemunaire 2018-09-18 23:01:19 +02:00
parent bd76956b46
commit b3351cb3c9

View File

@ -1,6 +1,7 @@
package main
import (
"encoding/base64"
"errors"
"image"
_ "image/gif"
@ -114,7 +115,7 @@ func AddImage(filename string, blob io.ReadCloser) error {
return errors.New("This filename is already used, please choose another one.")
// Convert to JPEG
} else if img, _, err := image.Decode(blob); err != nil {
} else if img, _, err := image.Decode(base64.NewDecoder(base64.StdEncoding, blob)); err != nil {
return err
// Save file