update the comment for godoc
This commit is contained in:
3
auth.go
3
auth.go
@@ -219,8 +219,7 @@ type AuthorizationTransport struct {
|
|||||||
SessionToken string
|
SessionToken string
|
||||||
rwLocker sync.RWMutex
|
rwLocker sync.RWMutex
|
||||||
// 签名多久过期
|
// 签名多久过期
|
||||||
Expire time.Duration
|
Expire time.Duration
|
||||||
|
|
||||||
Transport http.RoundTripper
|
Transport http.RoundTripper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
bucket.go
16
bucket.go
@@ -6,12 +6,10 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BucketService ...
|
// BucketService 相关 API
|
||||||
//
|
|
||||||
// Bucket 相关 API
|
|
||||||
type BucketService service
|
type BucketService service
|
||||||
|
|
||||||
// BucketGetResult ...
|
// BucketGetResult is the result of GetBucket
|
||||||
type BucketGetResult struct {
|
type BucketGetResult struct {
|
||||||
XMLName xml.Name `xml:"ListBucketResult"`
|
XMLName xml.Name `xml:"ListBucketResult"`
|
||||||
Name string
|
Name string
|
||||||
@@ -26,7 +24,7 @@ type BucketGetResult struct {
|
|||||||
EncodingType string `xml:"Encoding-Type,omitempty"`
|
EncodingType string `xml:"Encoding-Type,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketGetOptions ...
|
// BucketGetOptions is the option of GetBucket
|
||||||
type BucketGetOptions struct {
|
type BucketGetOptions struct {
|
||||||
Prefix string `url:"prefix,omitempty"`
|
Prefix string `url:"prefix,omitempty"`
|
||||||
Delimiter string `url:"delimiter,omitempty"`
|
Delimiter string `url:"delimiter,omitempty"`
|
||||||
@@ -51,7 +49,7 @@ func (s *BucketService) Get(ctx context.Context, opt *BucketGetOptions) (*Bucket
|
|||||||
return &res, resp, err
|
return &res, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketPutOptions ...
|
// BucketPutOptions is same to the ACLHeaderOptions
|
||||||
type BucketPutOptions ACLHeaderOptions
|
type BucketPutOptions ACLHeaderOptions
|
||||||
|
|
||||||
// Put Bucket请求可以在指定账号下创建一个Bucket。
|
// Put Bucket请求可以在指定账号下创建一个Bucket。
|
||||||
@@ -98,9 +96,9 @@ func (s *BucketService) Head(ctx context.Context) (*Response, error) {
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bucket ...
|
// Bucket is the meta info of Bucket
|
||||||
type Bucket struct {
|
type Bucket struct {
|
||||||
Name string
|
Name string
|
||||||
Region string `xml:"Location,omitempty"`
|
Region string `xml:"Location,omitempty"`
|
||||||
CreationDate string `xml:",omitempty"`
|
CreationDate string `xml:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BucketGetACLResult ...
|
// BucketGetACLResult is same to the ACLXml
|
||||||
type BucketGetACLResult ACLXml
|
type BucketGetACLResult ACLXml
|
||||||
|
|
||||||
// GetACL 使用API读取Bucket的ACL表,只有所有者有权操作。
|
// GetACL 使用API读取Bucket的ACL表,只有所有者有权操作。
|
||||||
@@ -23,7 +23,7 @@ func (s *BucketService) GetACL(ctx context.Context) (*BucketGetACLResult, *Respo
|
|||||||
return &res, resp, err
|
return &res, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketPutACLOptions ...
|
// BucketPutACLOptions is the option of PutBucketACL
|
||||||
type BucketPutACLOptions struct {
|
type BucketPutACLOptions struct {
|
||||||
Header *ACLHeaderOptions `url:"-" xml:"-"`
|
Header *ACLHeaderOptions `url:"-" xml:"-"`
|
||||||
Body *ACLXml `url:"-" header:"-"`
|
Body *ACLXml `url:"-" header:"-"`
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BucketCORSRule ...
|
// BucketCORSRule is the rule of BucketCORS
|
||||||
type BucketCORSRule struct {
|
type BucketCORSRule struct {
|
||||||
ID string `xml:"ID,omitempty"`
|
ID string `xml:"ID,omitempty"`
|
||||||
AllowedMethods []string `xml:"AllowedMethod"`
|
AllowedMethods []string `xml:"AllowedMethod"`
|
||||||
@@ -16,15 +16,13 @@ type BucketCORSRule struct {
|
|||||||
ExposeHeaders []string `xml:"ExposeHeader,omitempty"`
|
ExposeHeaders []string `xml:"ExposeHeader,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketGetCORSResult ...
|
// BucketGetCORSResult is the result of GetBucketCORS
|
||||||
type BucketGetCORSResult struct {
|
type BucketGetCORSResult struct {
|
||||||
XMLName xml.Name `xml:"CORSConfiguration"`
|
XMLName xml.Name `xml:"CORSConfiguration"`
|
||||||
Rules []BucketCORSRule `xml:"CORSRule,omitempty"`
|
Rules []BucketCORSRule `xml:"CORSRule,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCORS ...
|
// GetCORS 实现 Bucket 跨域访问配置读取。
|
||||||
//
|
|
||||||
// Get Bucket CORS实现跨域访问配置读取。
|
|
||||||
//
|
//
|
||||||
// https://www.qcloud.com/document/product/436/8274
|
// https://www.qcloud.com/document/product/436/8274
|
||||||
func (s *BucketService) GetCORS(ctx context.Context) (*BucketGetCORSResult, *Response, error) {
|
func (s *BucketService) GetCORS(ctx context.Context) (*BucketGetCORSResult, *Response, error) {
|
||||||
@@ -39,15 +37,13 @@ func (s *BucketService) GetCORS(ctx context.Context) (*BucketGetCORSResult, *Res
|
|||||||
return &res, resp, err
|
return &res, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketPutCORSOptions ...
|
// BucketPutCORSOptions is the option of PutBucketCORS
|
||||||
type BucketPutCORSOptions struct {
|
type BucketPutCORSOptions struct {
|
||||||
XMLName xml.Name `xml:"CORSConfiguration"`
|
XMLName xml.Name `xml:"CORSConfiguration"`
|
||||||
Rules []BucketCORSRule `xml:"CORSRule,omitempty"`
|
Rules []BucketCORSRule `xml:"CORSRule,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutCORS ...
|
// PutCORS 实现 Bucket 跨域访问设置,您可以通过传入XML格式的配置文件实现配置,文件大小限制为64 KB。
|
||||||
//
|
|
||||||
// Put Bucket CORS实现跨域访问设置,您可以通过传入XML格式的配置文件实现配置,文件大小限制为64 KB。
|
|
||||||
//
|
//
|
||||||
// https://www.qcloud.com/document/product/436/8279
|
// https://www.qcloud.com/document/product/436/8279
|
||||||
func (s *BucketService) PutCORS(ctx context.Context, opt *BucketPutCORSOptions) (*Response, error) {
|
func (s *BucketService) PutCORS(ctx context.Context, opt *BucketPutCORSOptions) (*Response, error) {
|
||||||
@@ -61,9 +57,7 @@ func (s *BucketService) PutCORS(ctx context.Context, opt *BucketPutCORSOptions)
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteCORS ...
|
// DeleteCORS 实现 Bucket 跨域访问配置删除。
|
||||||
//
|
|
||||||
// Delete Bucket CORS实现跨域访问配置删除。
|
|
||||||
//
|
//
|
||||||
// https://www.qcloud.com/document/product/436/8283
|
// https://www.qcloud.com/document/product/436/8283
|
||||||
func (s *BucketService) DeleteCORS(ctx context.Context) (*Response, error) {
|
func (s *BucketService) DeleteCORS(ctx context.Context) (*Response, error) {
|
||||||
|
|||||||
@@ -5,51 +5,47 @@ import (
|
|||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
// BucketLifecycleFilter ...
|
|
||||||
|
// BucketLifecycleFilter is the param of BucketLifecycleRule
|
||||||
type BucketLifecycleFilter struct {
|
type BucketLifecycleFilter struct {
|
||||||
Prefix string `xml:"Prefix,omitempty"`
|
Prefix string `xml:"Prefix,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketLifecycleExpiration ...
|
// BucketLifecycleExpiration is the param of BucketLifecycleRule
|
||||||
type BucketLifecycleExpiration struct {
|
type BucketLifecycleExpiration struct {
|
||||||
Date string `xml:"Date,omitempty"`
|
Date string `xml:"Date,omitempty"`
|
||||||
Days int `xml:"Days,omitempty"`
|
Days int `xml:"Days,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketLifecycleTransition ...
|
// BucketLifecycleTransition is the param of BucketLifecycleRule
|
||||||
type BucketLifecycleTransition struct {
|
type BucketLifecycleTransition struct {
|
||||||
Date string `xml:"Date,omitempty"`
|
Date string `xml:"Date,omitempty"`
|
||||||
Days int `xml:"Days,omitempty"`
|
Days int `xml:"Days,omitempty"`
|
||||||
StorageClass string
|
StorageClass string
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketLifecycleAbortIncompleteMultipartUpload ...
|
// BucketLifecycleAbortIncompleteMultipartUpload is the param of BucketLifecycleRule
|
||||||
type BucketLifecycleAbortIncompleteMultipartUpload struct {
|
type BucketLifecycleAbortIncompleteMultipartUpload struct {
|
||||||
DaysAfterInitiation string `xml:"DaysAfterInititation,omitempty"`
|
DaysAfterInitiation string `xml:"DaysAfterInititation,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketLifecycleRule ...
|
// BucketLifecycleRule is the rule of BucketLifecycle
|
||||||
type BucketLifecycleRule struct {
|
type BucketLifecycleRule struct {
|
||||||
ID string `xml:"ID,omitempty"`
|
ID string `xml:"ID,omitempty"`
|
||||||
Status string
|
Status string
|
||||||
Filter *BucketLifecycleFilter `xml:"Filter,omitempty"`
|
Filter *BucketLifecycleFilter `xml:"Filter,omitempty"`
|
||||||
Transition *BucketLifecycleTransition `xml:"Transition,omitempty"`
|
Transition *BucketLifecycleTransition `xml:"Transition,omitempty"`
|
||||||
Expiration *BucketLifecycleExpiration `xml:"Expiration,omitempty"`
|
Expiration *BucketLifecycleExpiration `xml:"Expiration,omitempty"`
|
||||||
AbortIncompleteMultipartUpload *BucketLifecycleAbortIncompleteMultipartUpload `xml:"AbortIncompleteMultipartUpload,omitempty"`
|
AbortIncompleteMultipartUpload *BucketLifecycleAbortIncompleteMultipartUpload `xml:"AbortIncompleteMultipartUpload,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketGetLifecycleResult ...
|
// BucketGetLifecycleResult is the result of BucketGetLifecycle
|
||||||
type BucketGetLifecycleResult struct {
|
type BucketGetLifecycleResult struct {
|
||||||
XMLName xml.Name `xml:"LifecycleConfiguration"`
|
XMLName xml.Name `xml:"LifecycleConfiguration"`
|
||||||
Rules []BucketLifecycleRule `xml:"Rule,omitempty"`
|
Rules []BucketLifecycleRule `xml:"Rule,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLifecycle ...
|
// GetLifecycle 请求实现读取生命周期管理的配置。当配置不存在时,返回404 Not Found。
|
||||||
//
|
|
||||||
// Get Bucket Lifecycle请求实现读取生命周期管理的配置。当配置不存在时,返回404 Not Found。
|
|
||||||
//
|
|
||||||
// (目前只支持华南园区)
|
|
||||||
//
|
|
||||||
// https://www.qcloud.com/document/product/436/8278
|
// https://www.qcloud.com/document/product/436/8278
|
||||||
func (s *BucketService) GetLifecycle(ctx context.Context) (*BucketGetLifecycleResult, *Response, error) {
|
func (s *BucketService) GetLifecycle(ctx context.Context) (*BucketGetLifecycleResult, *Response, error) {
|
||||||
var res BucketGetLifecycleResult
|
var res BucketGetLifecycleResult
|
||||||
@@ -63,20 +59,14 @@ func (s *BucketService) GetLifecycle(ctx context.Context) (*BucketGetLifecycleRe
|
|||||||
return &res, resp, err
|
return &res, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketPutLifecycleOptions ...
|
// BucketPutLifecycleOptions is the option of PutBucketLifecycle
|
||||||
type BucketPutLifecycleOptions struct {
|
type BucketPutLifecycleOptions struct {
|
||||||
XMLName xml.Name `xml:"LifecycleConfiguration"`
|
XMLName xml.Name `xml:"LifecycleConfiguration"`
|
||||||
Rules []BucketLifecycleRule `xml:"Rule,omitempty"`
|
Rules []BucketLifecycleRule `xml:"Rule,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutLifecycle ...
|
// PutLifecycle 请求实现设置生命周期管理的功能。您可以通过该请求实现数据的生命周期管理配置和定期删除。
|
||||||
//
|
|
||||||
// Put Bucket Lifecycle请求实现设置生命周期管理的功能。您可以通过该请求实现数据的生命周期管理配置和定期删除。
|
|
||||||
//
|
|
||||||
// 此请求为覆盖操作,上传新的配置文件将覆盖之前的配置文件。生命周期管理对文件和文件夹同时生效。
|
// 此请求为覆盖操作,上传新的配置文件将覆盖之前的配置文件。生命周期管理对文件和文件夹同时生效。
|
||||||
//
|
|
||||||
// (目前只支持华南园区)
|
|
||||||
//
|
|
||||||
// https://www.qcloud.com/document/product/436/8280
|
// https://www.qcloud.com/document/product/436/8280
|
||||||
func (s *BucketService) PutLifecycle(ctx context.Context, opt *BucketPutLifecycleOptions) (*Response, error) {
|
func (s *BucketService) PutLifecycle(ctx context.Context, opt *BucketPutLifecycleOptions) (*Response, error) {
|
||||||
sendOpt := sendOptions{
|
sendOpt := sendOptions{
|
||||||
@@ -89,12 +79,7 @@ func (s *BucketService) PutLifecycle(ctx context.Context, opt *BucketPutLifecycl
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteLifecycle ...
|
// DeleteLifecycle 请求实现删除生命周期管理。
|
||||||
//
|
|
||||||
// Delete Bucket Lifecycle请求实现删除生命周期管理。
|
|
||||||
//
|
|
||||||
// (目前只支持华南园区)
|
|
||||||
//
|
|
||||||
// https://www.qcloud.com/document/product/436/8284
|
// https://www.qcloud.com/document/product/436/8284
|
||||||
func (s *BucketService) DeleteLifecycle(ctx context.Context) (*Response, error) {
|
func (s *BucketService) DeleteLifecycle(ctx context.Context) (*Response, error) {
|
||||||
sendOpt := sendOptions{
|
sendOpt := sendOptions{
|
||||||
|
|||||||
@@ -6,15 +6,13 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BucketGetLocationResult ...
|
// BucketGetLocationResult is the result of BucketGetLocation
|
||||||
type BucketGetLocationResult struct {
|
type BucketGetLocationResult struct {
|
||||||
XMLName xml.Name `xml:"LocationConstraint"`
|
XMLName xml.Name `xml:"LocationConstraint"`
|
||||||
Location string `xml:",chardata"`
|
Location string `xml:",chardata"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLocation ...
|
// GetLocation 接口获取Bucket所在地域信息,只有Bucket所有者有权限读取信息。
|
||||||
//
|
|
||||||
// Get Bucket Location接口获取Bucket所在地域信息,只有Bucket所有者有权限读取信息。
|
|
||||||
//
|
//
|
||||||
// https://www.qcloud.com/document/product/436/8275
|
// https://www.qcloud.com/document/product/436/8275
|
||||||
func (s *BucketService) GetLocation(ctx context.Context) (*BucketGetLocationResult, *Response, error) {
|
func (s *BucketService) GetLocation(ctx context.Context) (*BucketGetLocationResult, *Response, error) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListMultipartUploadsResult ...
|
// ListMultipartUploadsResult is the result of ListMultipartUploads
|
||||||
type ListMultipartUploadsResult struct {
|
type ListMultipartUploadsResult struct {
|
||||||
XMLName xml.Name `xml:"ListMultipartUploadsResult"`
|
XMLName xml.Name `xml:"ListMultipartUploadsResult"`
|
||||||
Bucket string `xml:"Bucket"`
|
Bucket string `xml:"Bucket"`
|
||||||
@@ -30,7 +30,7 @@ type ListMultipartUploadsResult struct {
|
|||||||
CommonPrefixes []string `xml:"CommonPrefixs>Prefix,omitempty"`
|
CommonPrefixes []string `xml:"CommonPrefixs>Prefix,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMultipartUploadsOptions ...
|
// ListMultipartUploadsOptions is the option of ListMultipartUploads
|
||||||
type ListMultipartUploadsOptions struct {
|
type ListMultipartUploadsOptions struct {
|
||||||
Delimiter string `url:"delimiter,omitempty"`
|
Delimiter string `url:"delimiter,omitempty"`
|
||||||
EncodingType string `url:"encoding-type,omitempty"`
|
EncodingType string `url:"encoding-type,omitempty"`
|
||||||
@@ -40,9 +40,7 @@ type ListMultipartUploadsOptions struct {
|
|||||||
UploadIDMarker string `url:"upload-id-marker,omitempty"`
|
UploadIDMarker string `url:"upload-id-marker,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMultipartUploads ...
|
// ListMultipartUploads 用来查询正在进行中的分块上传。单次最多列出1000个正在进行中的分块上传。
|
||||||
//
|
|
||||||
// List Multipart Uploads用来查询正在进行中的分块上传。单次最多列出1000个正在进行中的分块上传。
|
|
||||||
//
|
//
|
||||||
// https://www.qcloud.com/document/product/436/7736
|
// https://www.qcloud.com/document/product/436/7736
|
||||||
func (s *BucketService) ListMultipartUploads(ctx context.Context, opt *ListMultipartUploadsOptions) (*ListMultipartUploadsResult, *Response, error) {
|
func (s *BucketService) ListMultipartUploads(ctx context.Context, opt *ListMultipartUploadsOptions) (*ListMultipartUploadsResult, *Response, error) {
|
||||||
|
|||||||
@@ -6,21 +6,19 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BucketTaggingTag ...
|
// BucketTaggingTag is the tag of BucketTagging
|
||||||
type BucketTaggingTag struct {
|
type BucketTaggingTag struct {
|
||||||
Key string
|
Key string
|
||||||
Value string
|
Value string
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketGetTaggingResult ...
|
// BucketGetTaggingResult is the result of BucketGetTagging
|
||||||
type BucketGetTaggingResult struct {
|
type BucketGetTaggingResult struct {
|
||||||
XMLName xml.Name `xml:"Tagging"`
|
XMLName xml.Name `xml:"Tagging"`
|
||||||
TagSet []BucketTaggingTag `xml:"TagSet>Tag,omitempty"`
|
TagSet []BucketTaggingTag `xml:"TagSet>Tag,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTagging ...
|
// GetTagging 接口实现获取指定Bucket的标签。
|
||||||
//
|
|
||||||
// Get Bucket Tagging接口实现获取指定Bucket的标签。
|
|
||||||
//
|
//
|
||||||
// https://www.qcloud.com/document/product/436/8277
|
// https://www.qcloud.com/document/product/436/8277
|
||||||
func (s *BucketService) GetTagging(ctx context.Context) (*BucketGetTaggingResult, *Response, error) {
|
func (s *BucketService) GetTagging(ctx context.Context) (*BucketGetTaggingResult, *Response, error) {
|
||||||
@@ -35,15 +33,13 @@ func (s *BucketService) GetTagging(ctx context.Context) (*BucketGetTaggingResult
|
|||||||
return &res, resp, err
|
return &res, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketPutTaggingOptions ...
|
// BucketPutTaggingOptions is the option of BucketPutTagging
|
||||||
type BucketPutTaggingOptions struct {
|
type BucketPutTaggingOptions struct {
|
||||||
XMLName xml.Name `xml:"Tagging"`
|
XMLName xml.Name `xml:"Tagging"`
|
||||||
TagSet []BucketTaggingTag `xml:"TagSet>Tag,omitempty"`
|
TagSet []BucketTaggingTag `xml:"TagSet>Tag,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutTagging ...
|
// PutTagging 接口实现给用指定Bucket打标签。用来组织和管理相关Bucket。
|
||||||
//
|
|
||||||
// Put Bucket Tagging接口实现给用指定Bucket打标签。用来组织和管理相关Bucket。
|
|
||||||
//
|
//
|
||||||
// 当该请求设置相同Key名称,不同Value时,会返回400。请求成功,则返回204。
|
// 当该请求设置相同Key名称,不同Value时,会返回400。请求成功,则返回204。
|
||||||
//
|
//
|
||||||
@@ -59,9 +55,7 @@ func (s *BucketService) PutTagging(ctx context.Context, opt *BucketPutTaggingOpt
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteTagging ...
|
// DeleteTagging 接口实现删除指定Bucket的标签。
|
||||||
//
|
|
||||||
// Delete Bucket Tagging接口实现删除指定Bucket的标签。
|
|
||||||
//
|
//
|
||||||
// https://www.qcloud.com/document/product/436/8286
|
// https://www.qcloud.com/document/product/436/8286
|
||||||
func (s *BucketService) DeleteTagging(ctx context.Context) (*Response, error) {
|
func (s *BucketService) DeleteTagging(ctx context.Context) (*Response, error) {
|
||||||
|
|||||||
16
cos.go
16
cos.go
@@ -20,7 +20,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Version ...
|
// Version current go sdk version
|
||||||
Version = "0.7.3"
|
Version = "0.7.3"
|
||||||
userAgent = "cos-go-sdk-v5/" + Version
|
userAgent = "cos-go-sdk-v5/" + Version
|
||||||
contentTypeXML = "application/xml"
|
contentTypeXML = "application/xml"
|
||||||
@@ -65,7 +65,7 @@ func NewBucketURL(bucketName, region string, secure bool) *url.URL {
|
|||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// A Client manages communication with the COS API.
|
// Client is a client manages communication with the COS API.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
client *http.Client
|
client *http.Client
|
||||||
|
|
||||||
@@ -295,14 +295,14 @@ func addHeaderOptions(header http.Header, opt interface{}) (http.Header, error)
|
|||||||
return header, nil
|
return header, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Owner ...
|
// Owner defines Bucket/Object's owner
|
||||||
type Owner struct {
|
type Owner struct {
|
||||||
UIN string `xml:"uin,omitempty"`
|
UIN string `xml:"uin,omitempty"`
|
||||||
ID string `xml:",omitempty"`
|
ID string `xml:",omitempty"`
|
||||||
DisplayName string `xml:",omitempty"`
|
DisplayName string `xml:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initiator ...
|
// Initiator same to the Owner struct
|
||||||
type Initiator Owner
|
type Initiator Owner
|
||||||
|
|
||||||
// Response API 响应
|
// Response API 响应
|
||||||
@@ -316,7 +316,7 @@ func newResponse(resp *http.Response) *Response {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ACLHeaderOptions ...
|
// ACLHeaderOptions is the option of ACLHeader
|
||||||
type ACLHeaderOptions struct {
|
type ACLHeaderOptions struct {
|
||||||
XCosACL string `header:"x-cos-acl,omitempty" url:"-" xml:"-"`
|
XCosACL string `header:"x-cos-acl,omitempty" url:"-" xml:"-"`
|
||||||
XCosGrantRead string `header:"x-cos-grant-read,omitempty" url:"-" xml:"-"`
|
XCosGrantRead string `header:"x-cos-grant-read,omitempty" url:"-" xml:"-"`
|
||||||
@@ -324,7 +324,7 @@ type ACLHeaderOptions struct {
|
|||||||
XCosGrantFullControl string `header:"x-cos-grant-full-control,omitempty" url:"-" xml:"-"`
|
XCosGrantFullControl string `header:"x-cos-grant-full-control,omitempty" url:"-" xml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ACLGrantee ...
|
// ACLGrantee is the param of ACLGrant
|
||||||
type ACLGrantee struct {
|
type ACLGrantee struct {
|
||||||
Type string `xml:"type,attr"`
|
Type string `xml:"type,attr"`
|
||||||
UIN string `xml:"uin,omitempty"`
|
UIN string `xml:"uin,omitempty"`
|
||||||
@@ -333,13 +333,13 @@ type ACLGrantee struct {
|
|||||||
SubAccount string `xml:"Subaccount,omitempty"`
|
SubAccount string `xml:"Subaccount,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ACLGrant ...
|
// ACLGrant is the param of ACLXml
|
||||||
type ACLGrant struct {
|
type ACLGrant struct {
|
||||||
Grantee *ACLGrantee
|
Grantee *ACLGrantee
|
||||||
Permission string
|
Permission string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ACLXml ...
|
// ACLXml is the ACL body struct
|
||||||
type ACLXml struct {
|
type ACLXml struct {
|
||||||
XMLName xml.Name `xml:"AccessControlPolicy"`
|
XMLName xml.Name `xml:"AccessControlPolicy"`
|
||||||
Owner *Owner
|
Owner *Owner
|
||||||
|
|||||||
24
doc.go
24
doc.go
@@ -1,29 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Package cos 腾讯云对象存储服务 COS(Cloud Object Storage) Go SDK。
|
Package cos 腾讯云对象存储服务 COS(Cloud Object Storage) Go SDK, 封装了 V5 版本的 XML API。
|
||||||
|
|
||||||
|
|
||||||
COS API Version
|
|
||||||
|
|
||||||
封装了 V5 版本的 XML API 。
|
|
||||||
|
|
||||||
|
|
||||||
Usage
|
|
||||||
|
|
||||||
在项目的 example 目录下有各个 API 的使用示例 。
|
在项目的 example 目录下有各个 API 的使用示例 。
|
||||||
|
|
||||||
|
|
||||||
Authentication
|
Authentication
|
||||||
|
|
||||||
默认所有 API 都是匿名访问. 如果想添加认证信息的话,可以通过自定义一个 http.Client 来添加认证信息.
|
默认所有 API 都是匿名访问. 如果想添加认证信息的话,可以通过自定义一个 http.Client 来添加认证信息.
|
||||||
|
|
||||||
比如, 使用内置的 AuthorizationTransport 来为请求增加 Authorization Header 签名信息:
|
比如, 使用内置的 AuthorizationTransport 来为请求增加 Authorization Header 签名信息:
|
||||||
|
|
||||||
client := cos.NewClient(b, &http.Client{
|
client := cos.NewClient(b, &http.Client{
|
||||||
Transport: &cos.AuthorizationTransport{
|
Transport: &cos.AuthorizationTransport{
|
||||||
SecretID: "COS_SECRETID",
|
SecretID: "COS_SECRETID",
|
||||||
SecretKey: "COS_SECRETKEY",
|
SecretKey: "COS_SECRETKEY",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package cos
|
package cos
|
||||||
|
|||||||
6
error.go
6
error.go
@@ -20,14 +20,14 @@ type ErrorResponse struct {
|
|||||||
TraceID string `xml:"TraceId,omitempty"`
|
TraceID string `xml:"TraceId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error ...
|
// Error returns the error msg
|
||||||
func (r *ErrorResponse) Error() string {
|
func (r *ErrorResponse) Error() string {
|
||||||
RequestID := r.RequestID
|
RequestID := r.RequestID
|
||||||
if (RequestID == "") {
|
if RequestID == "" {
|
||||||
RequestID = r.Response.Header["X-Cos-Request-Id"][0]
|
RequestID = r.Response.Header["X-Cos-Request-Id"][0]
|
||||||
}
|
}
|
||||||
TraceID := r.TraceID
|
TraceID := r.TraceID
|
||||||
if (TraceID == "") {
|
if TraceID == "" {
|
||||||
TraceID = r.Response.Header["X-Cos-Trace-Id"][0]
|
TraceID = r.Response.Header["X-Cos-Trace-Id"][0]
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%v %v: %d %v(Message: %v, RequestId: %v, TraceId: %v)",
|
return fmt.Sprintf("%v %v: %d %v(Message: %v, RequestId: %v, TraceId: %v)",
|
||||||
|
|||||||
37
object.go
37
object.go
@@ -9,12 +9,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ObjectService ...
|
// ObjectService 相关 API
|
||||||
//
|
|
||||||
// Object 相关 API
|
|
||||||
type ObjectService service
|
type ObjectService service
|
||||||
|
|
||||||
// ObjectGetOptions ...
|
// ObjectGetOptions is the option of GetObject
|
||||||
type ObjectGetOptions struct {
|
type ObjectGetOptions struct {
|
||||||
ResponseContentType string `url:"response-content-type,omitempty" header:"-"`
|
ResponseContentType string `url:"response-content-type,omitempty" header:"-"`
|
||||||
ResponseContentLanguage string `url:"response-content-language,omitempty" header:"-"`
|
ResponseContentLanguage string `url:"response-content-language,omitempty" header:"-"`
|
||||||
@@ -43,7 +41,7 @@ func (s *ObjectService) Get(ctx context.Context, name string, opt *ObjectGetOpti
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectPutHeaderOptions ...
|
// ObjectPutHeaderOptions the options of header of the put object
|
||||||
type ObjectPutHeaderOptions struct {
|
type ObjectPutHeaderOptions struct {
|
||||||
CacheControl string `header:"Cache-Control,omitempty" url:"-"`
|
CacheControl string `header:"Cache-Control,omitempty" url:"-"`
|
||||||
ContentDisposition string `header:"Content-Disposition,omitempty" url:"-"`
|
ContentDisposition string `header:"Content-Disposition,omitempty" url:"-"`
|
||||||
@@ -60,7 +58,7 @@ type ObjectPutHeaderOptions struct {
|
|||||||
//XCosObjectType string `header:"x-cos-object-type,omitempty" url:"-"`
|
//XCosObjectType string `header:"x-cos-object-type,omitempty" url:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectPutOptions ...
|
// ObjectPutOptions the options of put object
|
||||||
type ObjectPutOptions struct {
|
type ObjectPutOptions struct {
|
||||||
*ACLHeaderOptions `header:",omitempty" url:"-" xml:"-"`
|
*ACLHeaderOptions `header:",omitempty" url:"-" xml:"-"`
|
||||||
*ObjectPutHeaderOptions `header:",omitempty" url:"-" xml:"-"`
|
*ObjectPutHeaderOptions `header:",omitempty" url:"-" xml:"-"`
|
||||||
@@ -83,7 +81,7 @@ func (s *ObjectService) Put(ctx context.Context, name string, r io.Reader, opt *
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectCopyHeaderOptions ...
|
// ObjectCopyHeaderOptions is the head option of the Copy
|
||||||
type ObjectCopyHeaderOptions struct {
|
type ObjectCopyHeaderOptions struct {
|
||||||
XCosMetadataDirective string `header:"x-cos-metadata-directive,omitempty" url:"-" xml:"-"`
|
XCosMetadataDirective string `header:"x-cos-metadata-directive,omitempty" url:"-" xml:"-"`
|
||||||
XCosCopySourceIfModifiedSince string `header:"x-cos-copy-source-If-Modified-Since,omitempty" url:"-" xml:"-"`
|
XCosCopySourceIfModifiedSince string `header:"x-cos-copy-source-If-Modified-Since,omitempty" url:"-" xml:"-"`
|
||||||
@@ -96,21 +94,20 @@ type ObjectCopyHeaderOptions struct {
|
|||||||
XCosCopySource string `header:"x-cos-copy-source" url:"-" xml:"-"`
|
XCosCopySource string `header:"x-cos-copy-source" url:"-" xml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectCopyOptions ...
|
// ObjectCopyOptions is the option of Copy, choose header or body
|
||||||
type ObjectCopyOptions struct {
|
type ObjectCopyOptions struct {
|
||||||
*ObjectCopyHeaderOptions `header:",omitempty" url:"-" xml:"-"`
|
*ObjectCopyHeaderOptions `header:",omitempty" url:"-" xml:"-"`
|
||||||
*ACLHeaderOptions `header:",omitempty" url:"-" xml:"-"`
|
*ACLHeaderOptions `header:",omitempty" url:"-" xml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectCopyResult ...
|
// ObjectCopyResult is the result of Copy
|
||||||
type ObjectCopyResult struct {
|
type ObjectCopyResult struct {
|
||||||
XMLName xml.Name `xml:"CopyObjectResult"`
|
XMLName xml.Name `xml:"CopyObjectResult"`
|
||||||
ETag string `xml:"ETag,omitempty"`
|
ETag string `xml:"ETag,omitempty"`
|
||||||
LastModified string `xml:"LastModified,omitempty"`
|
LastModified string `xml:"LastModified,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy ...
|
// Copy 调用 PutObjectCopy 请求实现将一个文件从源路径复制到目标路径。建议文件大小 1M 到 5G,
|
||||||
// Put Object Copy 请求实现将一个文件从源路径复制到目标路径。建议文件大小 1M 到 5G,
|
|
||||||
// 超过 5G 的文件请使用分块上传 Upload - Copy。在拷贝的过程中,文件元属性和 ACL 可以被修改。
|
// 超过 5G 的文件请使用分块上传 Upload - Copy。在拷贝的过程中,文件元属性和 ACL 可以被修改。
|
||||||
//
|
//
|
||||||
// 用户可以通过该接口实现文件移动,文件重命名,修改文件属性和创建副本。
|
// 用户可以通过该接口实现文件移动,文件重命名,修改文件属性和创建副本。
|
||||||
@@ -153,7 +150,7 @@ func (s *ObjectService) Delete(ctx context.Context, name string) (*Response, err
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectHeadOptions ...
|
// ObjectHeadOptions is the option of HeadObject
|
||||||
type ObjectHeadOptions struct {
|
type ObjectHeadOptions struct {
|
||||||
IfModifiedSince string `url:"-" header:"If-Modified-Since,omitempty"`
|
IfModifiedSince string `url:"-" header:"If-Modified-Since,omitempty"`
|
||||||
}
|
}
|
||||||
@@ -176,7 +173,7 @@ func (s *ObjectService) Head(ctx context.Context, name string, opt *ObjectHeadOp
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectOptionsOptions ...
|
// ObjectOptionsOptions is the option of object options
|
||||||
type ObjectOptionsOptions struct {
|
type ObjectOptionsOptions struct {
|
||||||
Origin string `url:"-" header:"Origin"`
|
Origin string `url:"-" header:"Origin"`
|
||||||
AccessControlRequestMethod string `url:"-" header:"Access-Control-Request-Method"`
|
AccessControlRequestMethod string `url:"-" header:"Access-Control-Request-Method"`
|
||||||
@@ -199,7 +196,6 @@ func (s *ObjectService) Options(ctx context.Context, name string, opt *ObjectOpt
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append ...
|
|
||||||
// TODO Append 接口在优化未开放使用
|
// TODO Append 接口在优化未开放使用
|
||||||
//
|
//
|
||||||
// Append请求可以将一个文件(Object)以分块追加的方式上传至 Bucket 中。使用Append Upload的文件必须事前被设定为Appendable。
|
// Append请求可以将一个文件(Object)以分块追加的方式上传至 Bucket 中。使用Append Upload的文件必须事前被设定为Appendable。
|
||||||
@@ -231,7 +227,7 @@ func (s *ObjectService) Options(ctx context.Context, name string, opt *ObjectOpt
|
|||||||
// return resp, err
|
// return resp, err
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// ObjectDeleteMultiOptions ...
|
// ObjectDeleteMultiOptions is the option of DeleteMulti
|
||||||
type ObjectDeleteMultiOptions struct {
|
type ObjectDeleteMultiOptions struct {
|
||||||
XMLName xml.Name `xml:"Delete" header:"-"`
|
XMLName xml.Name `xml:"Delete" header:"-"`
|
||||||
Quiet bool `xml:"Quiet" header:"-"`
|
Quiet bool `xml:"Quiet" header:"-"`
|
||||||
@@ -239,7 +235,7 @@ type ObjectDeleteMultiOptions struct {
|
|||||||
//XCosSha1 string `xml:"-" header:"x-cos-sha1"`
|
//XCosSha1 string `xml:"-" header:"x-cos-sha1"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectDeleteMultiResult ...
|
// ObjectDeleteMultiResult is the result of DeleteMulti
|
||||||
type ObjectDeleteMultiResult struct {
|
type ObjectDeleteMultiResult struct {
|
||||||
XMLName xml.Name `xml:"DeleteResult"`
|
XMLName xml.Name `xml:"DeleteResult"`
|
||||||
DeletedObjects []Object `xml:"Deleted,omitempty"`
|
DeletedObjects []Object `xml:"Deleted,omitempty"`
|
||||||
@@ -250,14 +246,9 @@ type ObjectDeleteMultiResult struct {
|
|||||||
} `xml:"Error,omitempty"`
|
} `xml:"Error,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteMulti ...
|
// DeleteMulti 请求实现批量删除文件,最大支持单次删除1000个文件。
|
||||||
//
|
|
||||||
// Delete Multiple Object请求实现批量删除文件,最大支持单次删除1000个文件。
|
|
||||||
// 对于返回结果,COS提供Verbose和Quiet两种结果模式。Verbose模式将返回每个Object的删除结果;
|
// 对于返回结果,COS提供Verbose和Quiet两种结果模式。Verbose模式将返回每个Object的删除结果;
|
||||||
// Quiet模式只返回报错的Object信息。
|
// Quiet模式只返回报错的Object信息。
|
||||||
//
|
|
||||||
// 此请求必须携带x-cos-sha1用来校验Body的完整性。
|
|
||||||
//
|
|
||||||
// https://www.qcloud.com/document/product/436/8289
|
// https://www.qcloud.com/document/product/436/8289
|
||||||
func (s *ObjectService) DeleteMulti(ctx context.Context, opt *ObjectDeleteMultiOptions) (*ObjectDeleteMultiResult, *Response, error) {
|
func (s *ObjectService) DeleteMulti(ctx context.Context, opt *ObjectDeleteMultiOptions) (*ObjectDeleteMultiResult, *Response, error) {
|
||||||
var res ObjectDeleteMultiResult
|
var res ObjectDeleteMultiResult
|
||||||
@@ -272,7 +263,7 @@ func (s *ObjectService) DeleteMulti(ctx context.Context, opt *ObjectDeleteMultiO
|
|||||||
return &res, resp, err
|
return &res, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object ...
|
// Object is the meta info of the object
|
||||||
type Object struct {
|
type Object struct {
|
||||||
Key string `xml:",omitempty"`
|
Key string `xml:",omitempty"`
|
||||||
ETag string `xml:",omitempty"`
|
ETag string `xml:",omitempty"`
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ObjectGetACLResult ...
|
// ObjectGetACLResult is the result of GetObjectACL
|
||||||
type ObjectGetACLResult ACLXml
|
type ObjectGetACLResult ACLXml
|
||||||
|
|
||||||
// GetACL Get Object ACL接口实现使用API读取Object的ACL表,只有所有者有权操作。
|
// GetACL Get Object ACL接口实现使用API读取Object的ACL表,只有所有者有权操作。
|
||||||
@@ -23,7 +23,7 @@ func (s *ObjectService) GetACL(ctx context.Context, name string) (*ObjectGetACLR
|
|||||||
return &res, resp, err
|
return &res, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectPutACLOptions ...
|
// ObjectPutACLOptions the options of put object acl
|
||||||
type ObjectPutACLOptions struct {
|
type ObjectPutACLOptions struct {
|
||||||
Header *ACLHeaderOptions `url:"-" xml:"-"`
|
Header *ACLHeaderOptions `url:"-" xml:"-"`
|
||||||
Body *ACLXml `url:"-" header:"-"`
|
Body *ACLXml `url:"-" header:"-"`
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InitiateMultipartUploadOptions ...
|
// InitiateMultipartUploadOptions is the option of InitateMultipartUpload
|
||||||
type InitiateMultipartUploadOptions struct {
|
type InitiateMultipartUploadOptions struct {
|
||||||
*ACLHeaderOptions
|
*ACLHeaderOptions
|
||||||
*ObjectPutHeaderOptions
|
*ObjectPutHeaderOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitiateMultipartUploadResult ...
|
// InitiateMultipartUploadResult is the result of InitateMultipartUpload
|
||||||
type InitiateMultipartUploadResult struct {
|
type InitiateMultipartUploadResult struct {
|
||||||
XMLName xml.Name `xml:"InitiateMultipartUploadResult"`
|
XMLName xml.Name `xml:"InitiateMultipartUploadResult"`
|
||||||
Bucket string
|
Bucket string
|
||||||
@@ -22,9 +22,7 @@ type InitiateMultipartUploadResult struct {
|
|||||||
UploadID string `xml:"UploadId"`
|
UploadID string `xml:"UploadId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitiateMultipartUpload ...
|
// InitiateMultipartUpload 请求实现初始化分片上传,成功执行此请求以后会返回Upload ID用于后续的Upload Part请求。
|
||||||
//
|
|
||||||
// Initiate Multipart Upload请求实现初始化分片上传,成功执行此请求以后会返回Upload ID用于后续的Upload Part请求。
|
|
||||||
//
|
//
|
||||||
// https://www.qcloud.com/document/product/436/7746
|
// https://www.qcloud.com/document/product/436/7746
|
||||||
func (s *ObjectService) InitiateMultipartUpload(ctx context.Context, name string, opt *InitiateMultipartUploadOptions) (*InitiateMultipartUploadResult, *Response, error) {
|
func (s *ObjectService) InitiateMultipartUpload(ctx context.Context, name string, opt *InitiateMultipartUploadOptions) (*InitiateMultipartUploadResult, *Response, error) {
|
||||||
@@ -40,17 +38,14 @@ func (s *ObjectService) InitiateMultipartUpload(ctx context.Context, name string
|
|||||||
return &res, resp, err
|
return &res, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectUploadPartOptions ...
|
// ObjectUploadPartOptions is the options of upload-part
|
||||||
type ObjectUploadPartOptions struct {
|
type ObjectUploadPartOptions struct {
|
||||||
Expect string `header:"Expect,omitempty" url:"-"`
|
Expect string `header:"Expect,omitempty" url:"-"`
|
||||||
XCosContentSHA1 string `header:"x-cos-content-sha1" url:"-"`
|
XCosContentSHA1 string `header:"x-cos-content-sha1" url:"-"`
|
||||||
ContentLength int `header:"Content-Length,omitempty" url:"-"`
|
ContentLength int `header:"Content-Length,omitempty" url:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UploadPart 请求实现在初始化以后的分块上传,支持的块的数量为1到10000,块的大小为1 MB 到5 GB。
|
||||||
// UploadPart ...
|
|
||||||
//
|
|
||||||
// Upload Part请求实现在初始化以后的分块上传,支持的块的数量为1到10000,块的大小为1 MB 到5 GB。
|
|
||||||
// 在每次请求Upload Part时候,需要携带partNumber和uploadID,partNumber为块的编号,支持乱序上传。
|
// 在每次请求Upload Part时候,需要携带partNumber和uploadID,partNumber为块的编号,支持乱序上传。
|
||||||
//
|
//
|
||||||
// 当传入uploadID和partNumber都相同的时候,后传入的块将覆盖之前传入的块。当uploadID不存在时会返回404错误,NoSuchUpload.
|
// 当传入uploadID和partNumber都相同的时候,后传入的块将覆盖之前传入的块。当uploadID不存在时会返回404错误,NoSuchUpload.
|
||||||
@@ -71,14 +66,14 @@ func (s *ObjectService) UploadPart(ctx context.Context, name, uploadID string, p
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectListPartsOptions ...
|
// ObjectListPartsOptions is the option of ListParts
|
||||||
type ObjectListPartsOptions struct {
|
type ObjectListPartsOptions struct {
|
||||||
EncodingType string `url:"Encoding-type,omitempty"`
|
EncodingType string `url:"Encoding-type,omitempty"`
|
||||||
MaxParts int `url:"max-parts,omitempty"`
|
MaxParts int `url:"max-parts,omitempty"`
|
||||||
PartNumberMarker int `url:"part-number-marker,omitempty"`
|
PartNumberMarker int `url:"part-number-marker,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectListPartsResult ...
|
// ObjectListPartsResult is the result of ListParts
|
||||||
type ObjectListPartsResult struct {
|
type ObjectListPartsResult struct {
|
||||||
XMLName xml.Name `xml:"ListPartsResult"`
|
XMLName xml.Name `xml:"ListPartsResult"`
|
||||||
Bucket string
|
Bucket string
|
||||||
@@ -95,9 +90,7 @@ type ObjectListPartsResult struct {
|
|||||||
Parts []Object `xml:"Part,omitempty"`
|
Parts []Object `xml:"Part,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListParts ...
|
// ListParts 用来查询特定分块上传中的已上传的块。
|
||||||
//
|
|
||||||
// List Parts用来查询特定分块上传中的已上传的块。
|
|
||||||
//
|
//
|
||||||
// https://www.qcloud.com/document/product/436/7747
|
// https://www.qcloud.com/document/product/436/7747
|
||||||
func (s *ObjectService) ListParts(ctx context.Context, name, uploadID string) (*ObjectListPartsResult, *Response, error) {
|
func (s *ObjectService) ListParts(ctx context.Context, name, uploadID string) (*ObjectListPartsResult, *Response, error) {
|
||||||
@@ -113,13 +106,13 @@ func (s *ObjectService) ListParts(ctx context.Context, name, uploadID string) (*
|
|||||||
return &res, resp, err
|
return &res, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// CompleteMultipartUploadOptions ...
|
// CompleteMultipartUploadOptions is the option of CompleteMultipartUpload
|
||||||
type CompleteMultipartUploadOptions struct {
|
type CompleteMultipartUploadOptions struct {
|
||||||
XMLName xml.Name `xml:"CompleteMultipartUpload"`
|
XMLName xml.Name `xml:"CompleteMultipartUpload"`
|
||||||
Parts []Object `xml:"Part"`
|
Parts []Object `xml:"Part"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CompleteMultipartUploadResult ...
|
// CompleteMultipartUploadResult is the result CompleteMultipartUpload
|
||||||
type CompleteMultipartUploadResult struct {
|
type CompleteMultipartUploadResult struct {
|
||||||
XMLName xml.Name `xml:"CompleteMultipartUploadResult"`
|
XMLName xml.Name `xml:"CompleteMultipartUploadResult"`
|
||||||
Location string
|
Location string
|
||||||
@@ -128,9 +121,7 @@ type CompleteMultipartUploadResult struct {
|
|||||||
ETag string
|
ETag string
|
||||||
}
|
}
|
||||||
|
|
||||||
// CompleteMultipartUpload ...
|
// CompleteMultipartUpload 用来实现完成整个分块上传。当您已经使用Upload Parts上传所有块以后,你可以用该API完成上传。
|
||||||
//
|
|
||||||
// Complete Multipart Upload用来实现完成整个分块上传。当您已经使用Upload Parts上传所有块以后,你可以用该API完成上传。
|
|
||||||
// 在使用该API时,您必须在Body中给出每一个块的PartNumber和ETag,用来校验块的准确性。
|
// 在使用该API时,您必须在Body中给出每一个块的PartNumber和ETag,用来校验块的准确性。
|
||||||
//
|
//
|
||||||
// 由于分块上传的合并需要数分钟时间,因而当合并分块开始的时候,COS就立即返回200的状态码,在合并的过程中,
|
// 由于分块上传的合并需要数分钟时间,因而当合并分块开始的时候,COS就立即返回200的状态码,在合并的过程中,
|
||||||
@@ -158,9 +149,7 @@ func (s *ObjectService) CompleteMultipartUpload(ctx context.Context, name, uploa
|
|||||||
return &res, resp, err
|
return &res, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// AbortMultipartUpload ...
|
// AbortMultipartUpload 用来实现舍弃一个分块上传并删除已上传的块。当您调用Abort Multipart Upload时,
|
||||||
//
|
|
||||||
// Abort Multipart Upload用来实现舍弃一个分块上传并删除已上传的块。当您调用Abort Multipart Upload时,
|
|
||||||
// 如果有正在使用这个Upload Parts上传块的请求,则Upload Parts会返回失败。当该UploadID不存在时,会返回404 NoSuchUpload。
|
// 如果有正在使用这个Upload Parts上传块的请求,则Upload Parts会返回失败。当该UploadID不存在时,会返回404 NoSuchUpload。
|
||||||
//
|
//
|
||||||
// 建议您及时完成分块上传或者舍弃分块上传,因为已上传但是未终止的块会占用存储空间进而产生存储费用。
|
// 建议您及时完成分块上传或者舍弃分块上传,因为已上传但是未终止的块会占用存储空间进而产生存储费用。
|
||||||
|
|||||||
@@ -6,12 +6,10 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServiceService ...
|
|
||||||
//
|
|
||||||
// Service 相关 API
|
// Service 相关 API
|
||||||
type ServiceService service
|
type ServiceService service
|
||||||
|
|
||||||
// ServiceGetResult ...
|
// ServiceGetResult is the result of Get Service
|
||||||
type ServiceGetResult struct {
|
type ServiceGetResult struct {
|
||||||
XMLName xml.Name `xml:"ListAllMyBucketsResult"`
|
XMLName xml.Name `xml:"ListAllMyBucketsResult"`
|
||||||
Owner *Owner `xml:"Owner"`
|
Owner *Owner `xml:"Owner"`
|
||||||
|
|||||||
Reference in New Issue
Block a user