@@ -127,7 +127,7 @@ func (s *ObjectService) GetPresignedURL(ctx context.Context, httpMethod, name, a
127127 authTime = NewAuthTime (expired )
128128 }
129129 authorization := newAuthorization (ak , sk , req , authTime )
130- sign := encodeURIComponent (authorization , []byte {'&' ,'=' })
130+ sign := encodeURIComponent (authorization , []byte {'&' , '=' })
131131
132132 if req .URL .RawQuery == "" {
133133 req .URL .RawQuery = fmt .Sprintf ("%s" , sign )
@@ -181,6 +181,9 @@ type ObjectPutOptions struct {
181181//
182182// https://www.qcloud.com/document/product/436/7749
183183func (s * ObjectService ) Put (ctx context.Context , name string , r io.Reader , opt * ObjectPutOptions ) (* Response , error ) {
184+ if err := CheckReaderLen (r ); err != nil {
185+ return nil , err
186+ }
184187 if opt != nil && opt .Listener != nil {
185188 totalBytes , err := GetReaderLen (r )
186189 if err != nil {
@@ -802,28 +805,30 @@ func (s *ObjectService) Upload(ctx context.Context, name string, filepath string
802805 progressCallback (listener , event )
803806
804807 // 4.Push jobs
805- for _ , chunk := range chunks {
806- if chunk .Done {
807- continue
808- }
809- partOpt := & ObjectUploadPartOptions {}
810- if optini != nil && optini .ObjectPutHeaderOptions != nil {
811- partOpt .XCosSSECustomerAglo = optini .XCosSSECustomerAglo
812- partOpt .XCosSSECustomerKey = optini .XCosSSECustomerKey
813- partOpt .XCosSSECustomerKeyMD5 = optini .XCosSSECustomerKeyMD5
814- partOpt .XCosTrafficLimit = optini .XCosTrafficLimit
815- }
816- job := & Jobs {
817- Name : name ,
818- RetryTimes : 3 ,
819- FilePath : filepath ,
820- UploadId : uploadID ,
821- Chunk : chunk ,
822- Opt : partOpt ,
808+ go func () {
809+ for _ , chunk := range chunks {
810+ if chunk .Done {
811+ continue
812+ }
813+ partOpt := & ObjectUploadPartOptions {}
814+ if optini != nil && optini .ObjectPutHeaderOptions != nil {
815+ partOpt .XCosSSECustomerAglo = optini .XCosSSECustomerAglo
816+ partOpt .XCosSSECustomerKey = optini .XCosSSECustomerKey
817+ partOpt .XCosSSECustomerKeyMD5 = optini .XCosSSECustomerKeyMD5
818+ partOpt .XCosTrafficLimit = optini .XCosTrafficLimit
819+ }
820+ job := & Jobs {
821+ Name : name ,
822+ RetryTimes : 3 ,
823+ FilePath : filepath ,
824+ UploadId : uploadID ,
825+ Chunk : chunk ,
826+ Opt : partOpt ,
827+ }
828+ chjobs <- job
823829 }
824- chjobs <- job
825- }
826- close (chjobs )
830+ close (chjobs )
831+ }()
827832
828833 // 5.Recv the resp etag to complete
829834 for i := 0 ; i < partNum ; i ++ {
@@ -854,6 +859,7 @@ func (s *ObjectService) Upload(ctx context.Context, name string, filepath string
854859 event = newProgressEvent (ProgressDataEvent , chunks [res .PartNumber - 1 ].Size , consumedBytes , totalBytes )
855860 progressCallback (listener , event )
856861 }
862+ close (chresults )
857863 sort .Sort (ObjectList (optcom .Parts ))
858864
859865 event = newProgressEvent (ProgressCompletedEvent , 0 , consumedBytes , totalBytes )
0 commit comments