收藏
回答

golang 图片上传 签名失败

加密字符串:WECHATPAY2-SHA256-RSA2048 mchid="1605298545",nonce_str="51d6cf6a3a40073c185d045f9965ed99",signature="J96edK6pKk4qyukCKbPFHvBOt9XehHuJQfbZg/qrjuCy9fKfu4+BR+jupzIb08QIds9+u1pSeXC9uB3B9iRBI/buTM131P02Nuu3+DVtUtp8PQrgh6pPPUYbn5Gw2vAdpg/5jt/XAUt9+B3WeSG8pdb70P1qA21L2Qq7JP2/8urUtagQiFkcLYdhF5fYpTbKgugOKpdsDcIsiR9dWdud01GCZ9S9n9TqQSUH1PSpRZoZHuleOJlBdgn1+MO05RW7aoRczNVEKNxpuogwtKu3zVWHbB0OsLwZRiuicyOxeF34oU5ybcp1omQIHfaJgIAe/jsempUhrFveUDRFV1RNlA==",timestamp="1609915926",serial_no="56320EBFF57E06D8F2F613571C736252165FC00C"

meta 信息

filename:c6gnocc1pdtcdkcjh7.jpg

sha256 :eb7ad44f7ba1de7f282520b624fe3c10ed31af67


文件摘要 文件加密函数

func EncryptFile(path string) (encrypt string, err error) {

f, err := os.Open(path)

if err != nil {

return "", err

}

defer f.Close()

h := sha1.New()

_, err = io.Copy(h, f)

if err != nil {

return "", err

}

return hex.EncodeToString(h.Sum(nil)), nil

}


请求方法

r, e := ghttp.NewClient().Header(g.MapStrStr{

"Content-Type": "application/json",

"Accept": "application/json",

"Authorization": authorization,

}).Post( core.BuildUrl(nil, nil, core.ApiMediaUpload), "upload-file=@file:"+req.File,req)

if e != nil {

return nil,e

} else {

glog.Infof("res:%s",r.ReadAllString())

r.Close()

}


    返回数据


    {"code":"SIGN_ERROR","detail":{"detail":{"issue":"sign not match"},"field":"signature","location":"authorization","sign_information":{"method":"POST","sign_message_length":76,"truncated_sign_message":"POST\n/v3/merchant/media/upload\n1609915926\n51d6cf6a3a40073c185d045f9965ed99\n\n","url":"/v3/merchant/media/upload"}},"message":"错误的签名,验签失败"}


回答关注问题邀请回答
收藏

1 个回答

  • 支付社区运营-Tasting
    支付社区运营-Tasting
    2021-01-06

    麻烦提供下调用的API接口和接口文档地址哈~

    2021-01-06
    有用
    回复
登录 后发表内容
问题标签