diff --git a/bucket_lifecycle.go b/bucket_lifecycle.go
index bea3c16..4685a73 100644
--- a/bucket_lifecycle.go
+++ b/bucket_lifecycle.go
@@ -20,8 +20,9 @@ type BucketLifecycleFilter struct {
// BucketLifecycleExpiration is the param of BucketLifecycleRule
type BucketLifecycleExpiration struct {
- Date string `xml:"Date,omitempty"`
- Days int `xml:"Days,omitempty"`
+ Date string `xml:"Date,omitempty"`
+ Days int `xml:"Days,omitempty"`
+ ExpiredObjectDeleteMarker bool `xml:"ExpiredObjectDeleteMarker,omitempty"`
}
// BucketLifecycleTransition is the param of BucketLifecycleRule
@@ -31,6 +32,11 @@ type BucketLifecycleTransition struct {
StorageClass string
}
+type BucketLifecycleNoncurrentVersion struct {
+ NoncurrentDays int `xml:"NoncurrentDays,omitempty"`
+ StorageClass string `xml:"StorageClass,omitempty"`
+}
+
// BucketLifecycleAbortIncompleteMultipartUpload is the param of BucketLifecycleRule
type BucketLifecycleAbortIncompleteMultipartUpload struct {
DaysAfterInitiation int `xml:"DaysAfterInitiation,omitempty"`
@@ -41,9 +47,11 @@ type BucketLifecycleRule struct {
ID string `xml:"ID,omitempty"`
Status string
Filter *BucketLifecycleFilter `xml:"Filter,omitempty"`
- Transition *BucketLifecycleTransition `xml:"Transition,omitempty"`
+ Transition []BucketLifecycleTransition `xml:"Transition,omitempty"`
Expiration *BucketLifecycleExpiration `xml:"Expiration,omitempty"`
AbortIncompleteMultipartUpload *BucketLifecycleAbortIncompleteMultipartUpload `xml:"AbortIncompleteMultipartUpload,omitempty"`
+ NoncurrentVersionTransition []BucketLifecycleNoncurrentVersion `xml:"NoncurrentVersionTransition,omitempty"`
+ NoncurrentVersionExpiration *BucketLifecycleNoncurrentVersion `xml:"NoncurrentVersionExpiration,omitempty"`
}
// BucketGetLifecycleResult is the result of BucketGetLifecycle
diff --git a/bucket_lifecycle_test.go b/bucket_lifecycle_test.go
index fa7c479..9cbfa25 100644
--- a/bucket_lifecycle_test.go
+++ b/bucket_lifecycle_test.go
@@ -36,6 +36,20 @@ func TestBucketService_GetLifecycle(t *testing.T) {
10
Standard
+
+ 10
+
+
+ 90
+ ARCHIVE
+
+
+ 180
+ DEEP_ARCHIVE
+
+
+ 360
+
123422
@@ -68,8 +82,24 @@ func TestBucketService_GetLifecycle(t *testing.T) {
},
},
},
- Status: "Enabled",
- Transition: &BucketLifecycleTransition{Days: 10, StorageClass: "Standard"},
+ Status: "Enabled",
+ Transition: []BucketLifecycleTransition{
+ {Days: 10, StorageClass: "Standard"},
+ },
+ Expiration: &BucketLifecycleExpiration{Days: 10},
+ NoncurrentVersionExpiration: &BucketLifecycleNoncurrentVersion{
+ NoncurrentDays: 360,
+ },
+ NoncurrentVersionTransition: []BucketLifecycleNoncurrentVersion{
+ {
+ NoncurrentDays: 90,
+ StorageClass: "ARCHIVE",
+ },
+ {
+ NoncurrentDays: 180,
+ StorageClass: "DEEP_ARCHIVE",
+ },
+ },
},
{
ID: "123422",
@@ -92,10 +122,12 @@ func TestBucketService_PutLifecycle(t *testing.T) {
opt := &BucketPutLifecycleOptions{
Rules: []BucketLifecycleRule{
{
- ID: "1234",
- Filter: &BucketLifecycleFilter{Prefix: "test"},
- Status: "Enabled",
- Transition: &BucketLifecycleTransition{Days: 10, StorageClass: "Standard"},
+ ID: "1234",
+ Filter: &BucketLifecycleFilter{Prefix: "test"},
+ Status: "Enabled",
+ Transition: []BucketLifecycleTransition{
+ {Days: 10, StorageClass: "Standard"},
+ },
},
{
ID: "123422",
diff --git a/costesting/ci_test.go b/costesting/ci_test.go
index a44784f..fc9e31d 100644
--- a/costesting/ci_test.go
+++ b/costesting/ci_test.go
@@ -355,9 +355,11 @@ func (s *CosTestSuite) TestPutGetDeleteLifeCycle() {
ID: "1234",
Filter: &cos.BucketLifecycleFilter{Prefix: "test"},
Status: "Enabled",
- Transition: &cos.BucketLifecycleTransition{
- Days: 10,
- StorageClass: "Standard",
+ Transition: []cos.BucketLifecycleTransition{
+ {
+ Days: 10,
+ StorageClass: "Standard",
+ },
},
},
},
diff --git a/example/bucket/accelerate.go b/example/bucket/accelerate.go
index 49c2ff4..170e8ba 100644
--- a/example/bucket/accelerate.go
+++ b/example/bucket/accelerate.go
@@ -53,7 +53,6 @@ func main() {
opt := &cos.BucketPutAccelerateOptions{
Status: "Enabled",
- Type: "COS",
}
_, err = c.Bucket.PutAccelerate(context.Background(), opt)
log_status(err)
diff --git a/example/bucket/getLifecycle.go b/example/bucket/getLifecycle.go
index 8296d29..92da7ad 100644
--- a/example/bucket/getLifecycle.go
+++ b/example/bucket/getLifecycle.go
@@ -13,7 +13,7 @@ import (
)
func main() {
- u, _ := url.Parse("https://test-1253846586.cos.ap-guangzhou.myqcloud.com")
+ u, _ := url.Parse("https://test-1259654469.cos.ap-guangzhou.myqcloud.com")
b := &cos.BaseURL{
BucketURL: u,
}
@@ -35,6 +35,13 @@ func main() {
panic(err)
}
for _, r := range v.Rules {
- fmt.Printf("%s, %s\n", r.Filter.Prefix, r.Status)
+ fmt.Printf("%+v\n", r.ID)
+ fmt.Printf("%+v\n", r.Filter)
+ fmt.Printf("%+v\n", r.Status)
+ fmt.Printf("%+v\n", r.Transition)
+ fmt.Printf("%+v\n", r.Expiration)
+ fmt.Printf("%+v\n", r.NoncurrentVersionExpiration)
+ fmt.Printf("%+v\n", r.NoncurrentVersionTransition)
+ fmt.Printf("%+v\n", r.AbortIncompleteMultipartUpload)
}
}
diff --git a/example/bucket/putLifecycle.go b/example/bucket/putLifecycle.go
index 38bc05e..ec4464e 100644
--- a/example/bucket/putLifecycle.go
+++ b/example/bucket/putLifecycle.go
@@ -12,7 +12,7 @@ import (
)
func main() {
- u, _ := url.Parse("https://testhuanan-1253846586.cos.ap-guangzhou.myqcloud.com")
+ u, _ := url.Parse("https://test-1259654469.cos.ap-guangzhou.myqcloud.com")
b := &cos.BaseURL{
BucketURL: u,
}
@@ -35,18 +35,34 @@ func main() {
ID: "1234",
Filter: &cos.BucketLifecycleFilter{Prefix: "test"},
Status: "Enabled",
- Transition: &cos.BucketLifecycleTransition{
- Days: 10,
- StorageClass: "Standard",
+ Transition: []cos.BucketLifecycleTransition{
+ {
+ Days: 30,
+ StorageClass: "STANDARD_IA",
+ },
+ {
+ Days: 90,
+ StorageClass: "ARCHIVE",
+ },
},
- },
- {
- ID: "123422",
- // If used for all objecs set Prefix:""
- Filter: &cos.BucketLifecycleFilter{Prefix: "gg"},
- Status: "Disabled",
Expiration: &cos.BucketLifecycleExpiration{
- Days: 10,
+ Days: 360,
+ },
+ NoncurrentVersionExpiration: &cos.BucketLifecycleNoncurrentVersion{
+ NoncurrentDays: 360,
+ },
+ NoncurrentVersionTransition: []cos.BucketLifecycleNoncurrentVersion{
+ {
+ NoncurrentDays: 90,
+ StorageClass: "ARCHIVE",
+ },
+ {
+ NoncurrentDays: 180,
+ StorageClass: "DEEP_ARCHIVE",
+ },
+ },
+ AbortIncompleteMultipartUpload: &cos.BucketLifecycleAbortIncompleteMultipartUpload{
+ DaysAfterInitiation: 90,
},
},
},
diff --git a/object_select.go b/object_select.go
index a3c3c6d..64a4e2f 100644
--- a/object_select.go
+++ b/object_select.go
@@ -401,7 +401,6 @@ func (osr *ObjectSelectResponse) fixedLengthRead(p []byte, read_timeout int64) (
timeout := time.Duration(read_timeout)
r := osr.Body
ch := make(chan chanReadIO, 1)
- defer close(ch)
go func(p []byte) {
var needLen int
readChan := chanReadIO{}
@@ -412,6 +411,7 @@ func (osr *ObjectSelectResponse) fixedLengthRead(p []byte, read_timeout int64) (
if err != nil {
readChan.err = err
ch <- readChan
+ close(ch)
return
}
@@ -420,11 +420,12 @@ func (osr *ObjectSelectResponse) fixedLengthRead(p []byte, read_timeout int64) (
}
}
ch <- readChan
+ close(ch)
}(p)
select {
case <-time.After(time.Second * timeout):
- return 0, fmt.Errorf("requestId: %s, readLen timeout, timeout is %d(second),need read:%d", "sr.Headers.Get(HTTPHeaderOssRequestID)", timeout, len(p))
+ return 0, fmt.Errorf("requestId: %s, readLen timeout, timeout is %d(second),need read:%d", osr.Headers.Get("x-cos-request-id"), timeout, len(p))
case result := <-ch:
return result.readLen, result.err
}