本文整理匯總了Golang中github.com/guoyao/baidubce-sdk-go/bce.SignOption.AddHeaders方法的典型用法代碼示例。如果您正苦於以下問題:Golang SignOption.AddHeaders方法的具體用法?Golang SignOption.AddHeaders怎麽用?Golang SignOption.AddHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/guoyao/baidubce-sdk-go/bce.SignOption
的用法示例。
在下文中一共展示了SignOption.AddHeaders方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UploadPart
func (c *Client) UploadPart(uploadPartRequest UploadPartRequest,
option *bce.SignOption) (UploadPartResponse, error) {
bucketName := uploadPartRequest.BucketName
objectKey := uploadPartRequest.ObjectKey
checkBucketName(bucketName)
checkObjectKey(objectKey)
if uploadPartRequest.PartNumber < MIN_PART_NUMBER || uploadPartRequest.PartNumber > MAX_PART_NUMBER {
panic(fmt.Sprintf("Invalid partNumber %d. The valid range is from %d to %d.",
uploadPartRequest.PartNumber, MIN_PART_NUMBER, MAX_PART_NUMBER))
}
if uploadPartRequest.PartSize > 1024*1024*1024*5 {
panic(fmt.Sprintf("PartNumber %d: Part Size should not be more than 5GB.", uploadPartRequest.PartSize))
}
params := map[string]string{
"partNumber": strconv.Itoa(uploadPartRequest.PartNumber),
"uploadId": uploadPartRequest.UploadId,
}
req, err := bce.NewRequest("PUT", c.GetURL(bucketName, objectKey, params), uploadPartRequest.PartData)
if err != nil {
return nil, err
}
option = bce.CheckSignOption(option)
option.AddHeaders(map[string]string{
"Content-Length": strconv.FormatInt(uploadPartRequest.PartSize, 10),
"Content-Type": "application/octet-stream",
})
if _, ok := option.Headers["Content-MD5"]; !ok {
option.AddHeader("Content-MD5", util.GetMD5(uploadPartRequest.PartData, true))
}
resp, err := c.SendRequest(req, option)
if err != nil {
return nil, err
}
uploadPartResponse := NewUploadPartResponse(resp.Header)
return uploadPartResponse, nil
}
示例2: setBucketAclFromString
func (c *Client) setBucketAclFromString(bucketName, acl string, option *bce.SignOption) error {
params := map[string]string{"acl": ""}
req, err := bce.NewRequest("PUT", c.GetURL(bucketName, "", params), nil)
if err != nil {
return err
}
option = bce.CheckSignOption(option)
headers := map[string]string{"x-bce-acl": acl}
option.AddHeaders(headers)
_, err = c.SendRequest(req, option)
return err
}
示例3: mergeToSignOption
func (copyObjectRequest CopyObjectRequest) mergeToSignOption(option *bce.SignOption) {
m, err := util.ToMap(copyObjectRequest)
if err != nil {
return
}
headerMap := make(map[string]string)
for key, value := range m {
if str, ok := value.(string); ok {
headerMap[key] = str
}
}
option.AddHeaders(headerMap)
if copyObjectRequest.ObjectMetadata != nil {
option.AddHeader("x-bce-metadata-directive", "replace")
copyObjectRequest.ObjectMetadata.mergeToSignOption(option)
} else {
option.AddHeader("x-bce-metadata-directive", "copy")
}
}