全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

IP归属甄别会员请立即修改密码
查看: 252|回复: 0
打印 上一主题 下一主题

[不懂就问系列]go语言 阿里云OSS服务器回调处理

[复制链接]
跳转到指定楼层
1#
发表于 2020-3-23 16:24:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
RT

用户直传OSS,OSS返回上传信息到回调服务器使用POST请求。

我用GO接受请求,获取上传的文件信息(文件名,文件大小等)

r.Header没有相关字段

r.body返回的信息请问如何获取callback_body?

  1. func handlerRequest(w http.ResponseWriter, r *http.Request) {
  2.         if r.Method == "POST" {
  3.                 fmt.Println("\nHandle Post Request...")

  4.                 // Get PublicKey bytes
  5.                 bytePublicKey, err := getPublicKey(r)
  6.                 if err != nil {
  7.                         responseFailed(w)
  8.                         return
  9.                 }

  10.                 // Get Authorization bytes : decode from Base64String
  11.                 byteAuthorization, err := getAuthorization(r)
  12.                 if err != nil {
  13.                         responseFailed(w)
  14.                         return
  15.                 }

  16.                 // Get MD5 bytes from Newly Constructed Authrization String.
  17.                 byteMD5, err := getMD5FromNewAuthString(r)
  18.                 if err != nil {
  19.                         responseFailed(w)
  20.                         return
  21.                 }

  22.                 // VerifySignature and response to client
  23.                 if verifySignature(bytePublicKey, byteMD5, byteAuthorization) {

  24.                         // Do something you want accoding to callback_body ...

  25.                         // response OK : 200
  26.                         responseSuccess(w)
  27.                 } else {
  28.                         // response FAILED : 400
  29.                         responseFailed(w)
  30.                 }
  31.         }
  32. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-9-21 20:02 , Processed in 0.217827 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表