mirror of
https://github.com/fumiama/imoto.git
synced 2026-07-01 09:10:24 +08:00
optimize: limit bed to image
This commit is contained in:
5
image.go
5
image.go
@@ -9,6 +9,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/fumiama/imgsz"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,6 +36,10 @@ func Live(u string) bool {
|
|||||||
|
|
||||||
// Bed image to server
|
// Bed image to server
|
||||||
func Bed(t string, b []byte) (string, uint64, uint64, error) {
|
func Bed(t string, b []byte) (string, uint64, uint64, error) {
|
||||||
|
_, _, err := imgsz.DecodeSize(bytes.NewReader(b))
|
||||||
|
if err != nil {
|
||||||
|
return "", 0, 0, errors.Wrap(err, getThisFuncName())
|
||||||
|
}
|
||||||
m := md5.Sum(b)
|
m := md5.Sum(b)
|
||||||
u := API + hex.EncodeToString(m[:])
|
u := API + hex.EncodeToString(m[:])
|
||||||
req, err := http.NewRequest("PUT", u, bytes.NewReader(b))
|
req, err := http.NewRequest("PUT", u, bytes.NewReader(b))
|
||||||
|
|||||||
Reference in New Issue
Block a user