1
0
mirror of https://github.com/fumiama/imoto.git synced 2026-06-07 19:40:33 +08:00

optimize: limit bed to image

This commit is contained in:
源文雨
2023-11-17 14:01:46 +09:00
parent 296ec39945
commit 857ae11ebd

View File

@@ -9,6 +9,7 @@ import (
"net/http"
"strings"
"github.com/fumiama/imgsz"
"github.com/pkg/errors"
)
@@ -35,6 +36,10 @@ func Live(u string) bool {
// Bed image to server
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)
u := API + hex.EncodeToString(m[:])
req, err := http.NewRequest("PUT", u, bytes.NewReader(b))