浏览代码

add RequestPayer option

hangzws 7 年之前
父节点
当前提交
495cf2e064
共有 2 个文件被更改,包括 16 次插入0 次删除
  1. 11 0
      oss/const.go
  2. 5 0
      oss/option.go

+ 11 - 0
oss/const.go

@@ -44,6 +44,16 @@ const (
 	StorageArchive StorageClassType = "Archive"
 )
 
+// PayerType the type of request payer
+type PayerType string
+
+const (
+	// BucketOwner the owner of the bucket
+	BucketOwner PayerType = "BucketOwner"
+	// Requester the requester who send the request
+	Requester PayerType = "Requester"
+)
+
 // HTTPMethod HTTP request method
 type HTTPMethod string
 
@@ -109,6 +119,7 @@ const (
 	HTTPHeaderOssStorageClass                = "X-Oss-Storage-Class"
 	HTTPHeaderOssCallback                    = "X-Oss-Callback"
 	HTTPHeaderOssCallbackVar                 = "X-Oss-Callback-Var"
+	HTTPHeaderOSSRequester                   = "x-oss-request-payer"
 )
 
 // HTTP Param

+ 5 - 0
oss/option.go

@@ -187,6 +187,11 @@ func CallbackVar(callbackVar string) Option {
 	return setHeader(HTTPHeaderOssCallbackVar, callbackVar)
 }
 
+// RequestPayer is an option to set payer who pay for the request
+func RequestPayer(payerType PayerType) Option {
+	return setHeader(HTTPHeaderOSSRequester, payerType)
+}
+
 // Delimiter is an option to set delimiler parameter
 func Delimiter(value string) Option {
 	return addParam("delimiter", value)