跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • [不懂就问系列]go语言 阿里云OSS服务器回调处理
未分類
8 4 月 2020

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

beng 大佬有话说 : 2020-3-23 16:24:47

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

RT

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

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

r.Header没有相关字段

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

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

                // Get PublicKey bytes
                bytePublicKey, err := getPublicKey(r)
                if err != nil {
                        responseFailed(w)
                        return
                }

                // Get Authorization bytes : decode from Base64String
                byteAuthorization, err := getAuthorization(r)
                if err != nil {
                        responseFailed(w)
                        return
                }

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

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

                        // Do something you want accoding to callback_body …

                        // response OK : 200
                        responseSuccess(w)
                } else {
                        // response FAILED : 400
                        responseFailed(w)
                }
        }
}

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具