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:
parent
bd76956b46
commit
b3351cb3c9
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user