Ai
2 Star 10 Fork 0

tencentcloud/tencentcloud-sdk-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
common_client.go 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
15756313478 提交于 2021-12-08 16:48 +08:00 . support octet-stream (#153)
package common
import (
tcerr "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
tchttp "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
)
func NewCommonClient(cred CredentialIface, region string, clientProfile *profile.ClientProfile) (c *Client) {
return new(Client).Init(region).WithCredential(cred).WithProfile(clientProfile)
}
// SendOctetStream Invoke API with application/octet-stream content-type.
//
// Note:
// 1. only specific API can be invoked in such manner.
// 2. only TC3-HMAC-SHA256 signature method can be specified.
// 3. only POST request method can be specified
// 4. the request Must be a CommonRequest and called SetOctetStreamParameters
//
func (c *Client) SendOctetStream(request tchttp.Request, response tchttp.Response) (err error) {
if c.profile.SignMethod != "TC3-HMAC-SHA256" {
return tcerr.NewTencentCloudSDKError("ClientError", "Invalid signature method.", "")
}
if c.profile.HttpProfile.ReqMethod != "POST" {
return tcerr.NewTencentCloudSDKError("ClientError", "Invalid request method.", "")
}
//cr, ok := request.(*tchttp.CommonRequest)
//if !ok {
// return tcerr.NewTencentCloudSDKError("ClientError", "Invalid request, must be *CommonRequest!", "")
//}
//if !cr.IsOctetStream() {
// return tcerr.NewTencentCloudSDKError("ClientError", "Invalid request, does not meet the conditions for sending OctetStream", "")
//}
return c.Send(request, response)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tencentcloud/tencentcloud-sdk-go.git
git@gitee.com:tencentcloud/tencentcloud-sdk-go.git
tencentcloud
tencentcloud-sdk-go
tencentcloud-sdk-go
master

搜索帮助