上传回调服务

上传回调服务响应OSS发送给应用服务器的POST消息,代码片段如下。

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 Authorization 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 according to callback_body ...

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

更多信息,请参见API文档Callback。