This commit is contained in:
苏尹岚
2021-04-21 09:25:35 +08:00
parent 077ff77417
commit be93f2d9c8
2 changed files with 12 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ package jdshopapi
import (
"bytes"
"crypto/md5"
"encoding/base64"
"fmt"
"image"
"image/gif"
@@ -41,14 +42,15 @@ func TestDeleteShopCategory(t *testing.T) {
}
func TestUploadPicture(t *testing.T) {
data, _, err := DownloadFileByURL("https://image.jxc4.com/noGoodsImg.jpg")
data, _, _ := DownloadFileByURL("http://image.jxc4.com/image/5de25b52598d7327b17399d6ddba0197.jpg")
// img, outMimeType, _ := Binary2Image(data, "")
// result2, _ := Image2Binary(img, outMimeType)
result, err := api.UploadPicture(data, 0, "noGoodsImg")
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
fmt.Println(base64.StdEncoding.EncodeToString(data))
//result, err := api.UploadPicture(data, 0, "noGoodsImg")
//if err != nil {
// t.Fatal(err)
//}
//t.Log(utils.Format4Output(result, false))
}
func DownloadFileByURL(fileURL string) (bodyData []byte, fileMD5 string, err error) {

View File

@@ -1,6 +1,7 @@
package mtunionapi
import (
"encoding/json"
"fmt"
"git.rosy.net.cn/baseapi/utils"
"io/ioutil"
@@ -40,7 +41,9 @@ func (a *API) GetCallbackMsg(request *http.Request) (call *CallBackResult, err e
}
mapData := utils.URLValues2Map(values)
fmt.Println("1111111111111111111", mapData)
utils.Map2StructByJson(mapData, &call, false)
for k, _ := range mapData {
json.Unmarshal([]byte(k), &call)
}
fmt.Println("2222222222222222222", utils.Format4Output(call, true))
return call, err
}