Browse Source
			
			
			Merge pull request #44 from likexian/master
			
				add Server Side Encryption Option to ObjectPutHeaderOptions and fixed testing
			
			
				tags/v0.7.8
			
			
		 
		
			
				
					
						
						toranger
					
					6 years ago
					
						
							committed by
							
								
								GitHub
							
						 
					
				 
				
			 
		 
		
			
				
				  
				  No known key found for this signature in database
				  
				  	
						GPG Key ID: 4AEE18F83AFDEB23
				  	
				  
				
			
		
		
		
	
		
			
				 7 changed files with 
37 additions and 
7 deletions
			 
			
		 
		
			
				- 
					
					
					 
					.travis.yml
				
 
			
				- 
					
					
					 
					auth_test.go
				
 
			
				- 
					
					
					 
					costesting/ci_test.go
				
 
			
				- 
					
					
					 
					go.mod
				
 
			
				- 
					
					
					 
					go.sum
				
 
			
				- 
					
					
					 
					object.go
				
 
			
				- 
					
					
					 
					object_part_test.go
				
 
			
		
		
			
				
					
					
						
							
								
									
										
											
	
		
			
				| 
					
					
						
							
						
					
					
				 | 
				@ -4,6 +4,8 @@ go: | 
			
		
		
	
		
			
				 | 
				 | 
				- '1.8' | 
				 | 
				 | 
				- '1.8' | 
			
		
		
	
		
			
				 | 
				 | 
				- '1.9' | 
				 | 
				 | 
				- '1.9' | 
			
		
		
	
		
			
				 | 
				 | 
				- 1.10.x | 
				 | 
				 | 
				- 1.10.x | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				- 1.11.x | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				- 1.12.x | 
			
		
		
	
		
			
				 | 
				 | 
				- master | 
				 | 
				 | 
				- master | 
			
		
		
	
		
			
				 | 
				 | 
				sudo: false | 
				 | 
				 | 
				sudo: false | 
			
		
		
	
		
			
				 | 
				 | 
				before_install: | 
				 | 
				 | 
				before_install: | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -15,8 +17,8 @@ install: | 
			
		
		
	
		
			
				 | 
				 | 
				- go build github.com/mattn/goveralls | 
				 | 
				 | 
				- go build github.com/mattn/goveralls | 
			
		
		
	
		
			
				 | 
				 | 
				script: | 
				 | 
				 | 
				script: | 
			
		
		
	
		
			
				 | 
				 | 
				- make test | 
				 | 
				 | 
				- make test | 
			
		
		
	
		
			
				 | 
				 | 
				- make ci-test | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				- go test -coverprofile=cover.out github.com/toranger/cos-go-sdk-v5 | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				# - make ci-test | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				# - go test -coverprofile=cover.out github.com/toranger/cos-go-sdk-v5 | 
			
		
		
	
		
			
				 | 
				 | 
				- "${TRAVIS_HOME}/gopath/bin/goveralls -service=travis-ci -coverprofile=cover.out" | 
				 | 
				 | 
				- "${TRAVIS_HOME}/gopath/bin/goveralls -service=travis-ci -coverprofile=cover.out" | 
			
		
		
	
		
			
				 | 
				 | 
				matrix: | 
				 | 
				 | 
				matrix: | 
			
		
		
	
		
			
				 | 
				 | 
				  allow_failures: | 
				 | 
				 | 
				  allow_failures: | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
					
				 | 
				
  | 
			
		
		
	
										
									
								
							
						 
					 
				 
			
		
			
				
					
					
						
							
								
									
										
											
	
		
			
				| 
					
					
						
							
						
					
					
				 | 
				@ -45,7 +45,10 @@ func TestAuthorizationTransport(t *testing.T) { | 
			
		
		
	
		
			
				 | 
				 | 
						} | 
				 | 
				 | 
						} | 
			
		
		
	
		
			
				 | 
				 | 
					}) | 
				 | 
				 | 
					}) | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
					client.client.Transport = &AuthorizationTransport{} | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					client.client.Transport = &AuthorizationTransport{ | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						SecretID:  "test", | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						SecretKey: "test", | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					} | 
			
		
		
	
		
			
				 | 
				 | 
					req, _ := http.NewRequest("GET", client.BaseURL.BucketURL.String(), nil) | 
				 | 
				 | 
					req, _ := http.NewRequest("GET", client.BaseURL.BucketURL.String(), nil) | 
			
		
		
	
		
			
				 | 
				 | 
					client.doAPI(context.Background(), req, nil, true) | 
				 | 
				 | 
					client.doAPI(context.Background(), req, nil, true) | 
			
		
		
	
		
			
				 | 
				 | 
				} | 
				 | 
				 | 
				} | 
			
		
		
	
										
									
								
							
						 
					 
				 
			
		
			
				
					
					
						
							
								
									
										
											
	
		
			
				| 
					
					
						
							
						
					
					
				 | 
				@ -6,7 +6,7 @@ import ( | 
			
		
		
	
		
			
				 | 
				 | 
					"fmt" | 
				 | 
				 | 
					"fmt" | 
			
		
		
	
		
			
				 | 
				 | 
					"github.com/stretchr/testify/assert" | 
				 | 
				 | 
					"github.com/stretchr/testify/assert" | 
			
		
		
	
		
			
				 | 
				 | 
					"github.com/stretchr/testify/suite" | 
				 | 
				 | 
					"github.com/stretchr/testify/suite" | 
			
		
		
	
		
			
				 | 
				 | 
					"github.com/toranger/cos-go-sdk-v5" | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					"github.com/tencentyun/cos-go-sdk-v5" | 
			
		
		
	
		
			
				 | 
				 | 
					"io/ioutil" | 
				 | 
				 | 
					"io/ioutil" | 
			
		
		
	
		
			
				 | 
				 | 
					"math/rand" | 
				 | 
				 | 
					"math/rand" | 
			
		
		
	
		
			
				 | 
				 | 
					"net/http" | 
				 | 
				 | 
					"net/http" | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
					
				 | 
				
  | 
			
		
		
	
										
									
								
							
						 
					 
				 
			
		
			
				
					
					
						
							
								
									
										
											
	
		
			
				| 
					
					
					
				 | 
				@ -0,0 +1,10 @@ | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				module github.com/tencentyun/cos-go-sdk-v5 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				go 1.12 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				require ( | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					github.com/google/go-querystring v1.0.0 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					github.com/mozillazg/go-httpheader v0.2.1 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					github.com/stretchr/testify v1.3.0 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				) | 
			
		
		
	
										
									
								
							
						 
					 
				 
			
		
			
				
					
					
						
							
								
									
										
											
	
		
			
				| 
					
					
					
				 | 
				@ -0,0 +1,13 @@ | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409 h1:DTQ/38ao/CfXsrK0cSAL+h4R/u0VVvfWLZEOlLwEROI= | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ= | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60= | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= | 
			
		
		
	
										
									
								
							
						 
					 
				 
			
		
			
				
					
					
						
							
								
									
										
											
	
		
			
				| 
					
					
						
							
						
					
					
				 | 
				@ -133,6 +133,8 @@ type ObjectPutHeaderOptions struct { | 
			
		
		
	
		
			
				 | 
				 | 
					XCosStorageClass string       `header:"x-cos-storage-class,omitempty" url:"-"` | 
				 | 
				 | 
					XCosStorageClass string       `header:"x-cos-storage-class,omitempty" url:"-"` | 
			
		
		
	
		
			
				 | 
				 | 
					// 可选值: Normal, Appendable
 | 
				 | 
				 | 
					// 可选值: Normal, Appendable
 | 
			
		
		
	
		
			
				 | 
				 | 
					//XCosObjectType string `header:"x-cos-object-type,omitempty" url:"-"`
 | 
				 | 
				 | 
					//XCosObjectType string `header:"x-cos-object-type,omitempty" url:"-"`
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				        // Enable Server Side Encryption, Only supported: AES256
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
					XCosServerSideEncryption string       `header:"x-cos-server-side-encryption,omitempty" url:"-" xml:"-"` | 
			
		
		
	
		
			
				 | 
				 | 
				} | 
				 | 
				 | 
				} | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				// ObjectPutOptions the options of put object
 | 
				 | 
				 | 
				// ObjectPutOptions the options of put object
 | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
					
				 | 
				
  | 
			
		
		
	
										
									
								
							
						 
					 
				 
			
		
			
				
					
					
						
							
								
									
										
											
	
		
			
				| 
					
					
						
							
						
					
					
				 | 
				@ -168,7 +168,7 @@ func TestObjectService_ListParts(t *testing.T) { | 
			
		
		
	
		
			
				 | 
				 | 
					}) | 
				 | 
				 | 
					}) | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
					ref, _, err := client.Object.ListParts(context.Background(), | 
				 | 
				 | 
					ref, _, err := client.Object.ListParts(context.Background(), | 
			
		
		
	
		
			
				 | 
				 | 
						name, uploadID) | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						name, uploadID, nil) | 
			
		
		
	
		
			
				 | 
				 | 
					if err != nil { | 
				 | 
				 | 
					if err != nil { | 
			
		
		
	
		
			
				 | 
				 | 
						t.Fatalf("Object.ListParts returned error: %v", err) | 
				 | 
				 | 
						t.Fatalf("Object.ListParts returned error: %v", err) | 
			
		
		
	
		
			
				 | 
				 | 
					} | 
				 | 
				 | 
					} | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -182,7 +182,7 @@ func TestObjectService_ListParts(t *testing.T) { | 
			
		
		
	
		
			
				 | 
				 | 
							ID:          "1253846586", | 
				 | 
				 | 
							ID:          "1253846586", | 
			
		
		
	
		
			
				 | 
				 | 
							DisplayName: "1253846586", | 
				 | 
				 | 
							DisplayName: "1253846586", | 
			
		
		
	
		
			
				 | 
				 | 
						}, | 
				 | 
				 | 
						}, | 
			
		
		
	
		
			
				 | 
				 | 
						PartNumberMarker: 0, | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						PartNumberMarker: "0", | 
			
		
		
	
		
			
				 | 
				 | 
						Initiator: &Initiator{ | 
				 | 
				 | 
						Initiator: &Initiator{ | 
			
		
		
	
		
			
				 | 
				 | 
							ID:          "qcs::cam::uin/100000760461:uin/100000760461", | 
				 | 
				 | 
							ID:          "qcs::cam::uin/100000760461:uin/100000760461", | 
			
		
		
	
		
			
				 | 
				 | 
							DisplayName: "100000760461", | 
				 | 
				 | 
							DisplayName: "100000760461", | 
			
		
		
	
	
		
			
				| 
					
					
					
						
							
						
					
				 | 
				@ -202,7 +202,7 @@ func TestObjectService_ListParts(t *testing.T) { | 
			
		
		
	
		
			
				 | 
				 | 
							}, | 
				 | 
				 | 
							}, | 
			
		
		
	
		
			
				 | 
				 | 
						}, | 
				 | 
				 | 
						}, | 
			
		
		
	
		
			
				 | 
				 | 
						StorageClass: "Standard", | 
				 | 
				 | 
						StorageClass: "Standard", | 
			
		
		
	
		
			
				 | 
				 | 
						MaxParts:     1000, | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
						MaxParts:     "1000", | 
			
		
		
	
		
			
				 | 
				 | 
						IsTruncated:  false, | 
				 | 
				 | 
						IsTruncated:  false, | 
			
		
		
	
		
			
				 | 
				 | 
					} | 
				 | 
				 | 
					} | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
					
				 | 
				
  |