@@ -241,7 +241,7 @@ void GetBucketLifecycle(qcloud_cos::CosAPI& cos,
241241  qcloud_cos::CosResult result = cos.GetBucketLifecycle (req, &resp);
242242
243243  const  std::vector<qcloud_cos::LifecycleRule>& rules = resp.GetRules ();
244-   for  (int  idx = 0 ; idx != rules.size (); ++idx) {
244+   for  (size_t  idx = 0 ; idx != rules.size (); ++idx) {
245245    std::cout << " id = " GetId () << std::endl;
246246  }
247247
@@ -395,14 +395,9 @@ void PutObjectByFileLimitTraffic(qcloud_cos::CosAPI& cos,
395395                                 const  std::string& bucket_name,
396396                                 const  std::string& object_name,
397397                                 const  std::string& file_path,
398-                                  const  uint64_t  traffic_limit,
399-                                  bool  set_header = true ) {
398+                                  const  uint64_t  traffic_limit) {
400399  qcloud_cos::PutObjectByFileReq req (bucket_name, object_name, file_path);
401-   if  (set_header) {
402-     req.SetTrafficLimitByHeader (StringUtil::Uint64ToString (traffic_limit));
403-   } else  {
404-     req.SetTrafficLimitByParam (StringUtil::Uint64ToString (traffic_limit));
405-   }
400+   req.SetTrafficLimit (traffic_limit);
406401  qcloud_cos::PutObjectByFileResp resp;
407402  qcloud_cos::CosResult result = cos.PutObject (req, &resp);
408403  std::cout << " ===================PutObjectFileLimitTrafficResponse===========" 
@@ -463,14 +458,9 @@ void GetObjectByFileLimitTraffic(qcloud_cos::CosAPI& cos,
463458                                 const  std::string& bucket_name,
464459                                 const  std::string& object_name,
465460                                 const  std::string& file_path,
466-                                  const  uint64_t  traffic_limit,
467-                                  bool  set_header = true ) {
461+                                  const  uint64_t  traffic_limit) {
468462  qcloud_cos::GetObjectByFileReq req (bucket_name, object_name, file_path);
469-   if  (set_header) {
470-     req.SetTrafficLimitByHeader (StringUtil::Uint64ToString (traffic_limit));
471-   } else  {
472-     req.SetTrafficLimitByParam (StringUtil::Uint64ToString (traffic_limit));
473-   }
463+   req.SetTrafficLimit (traffic_limit);
474464  qcloud_cos::GetObjectByFileResp resp;
475465
476466  qcloud_cos::CosResult result = cos.GetObject (req, &resp);
@@ -504,7 +494,7 @@ void MultiGetObject(qcloud_cos::CosAPI& cos, const std::string& bucket_name,
504494  qcloud_cos::MultiGetObjectReq req (bucket_name, object_name, file_path);
505495  qcloud_cos::MultiGetObjectResp resp;
506496
507-   qcloud_cos::CosResult result = cos.GetObject (req, &resp);
497+   qcloud_cos::CosResult result = cos.MultiGetObject (req, &resp);
508498  std::cout << " ===================GetObjectResponse=====================" 
509499            << std::endl;
510500  PrintResult (result, resp);
@@ -517,16 +507,11 @@ void MultiGetObjectLimitTraffic(qcloud_cos::CosAPI& cos,
517507                                const  std::string& bucket_name,
518508                                const  std::string& object_name,
519509                                const  std::string& file_path,
520-                                 const  uint64_t  traffic_limit,
521-                                 bool  set_header = true ) {
510+                                 const  uint64_t  traffic_limit) {
522511  qcloud_cos::MultiGetObjectReq req (bucket_name, object_name, file_path);
523-   if  (set_header) {
524-     req.SetTrafficLimitByHeader (StringUtil::Uint64ToString (traffic_limit));
525-   } else  {
526-     req.SetTrafficLimitByParam (StringUtil::Uint64ToString (traffic_limit));
527-   }
512+   req.SetTrafficLimit (traffic_limit);
528513  qcloud_cos::MultiGetObjectResp resp;
529-   qcloud_cos::CosResult result = cos.GetObject (req, &resp);
514+   qcloud_cos::CosResult result = cos.MultiGetObject (req, &resp);
530515  std::cout << " ===================MultiGetObjectLimitTrafficResponse==========" 
531516               " ===========" 
532517            << std::endl;
@@ -571,15 +556,10 @@ void UploadPartDataLimitTraffic(qcloud_cos::CosAPI& cos,
571556                                const  std::string& object_name,
572557                                const  std::string& upload_id, std::fstream& is,
573558                                uint64_t  number, std::string* etag,
574-                                 const  uint64_t  traffic_limit,
575-                                 bool  set_header = true ) {
559+                                 const  uint64_t  traffic_limit) {
576560  qcloud_cos::UploadPartDataReq req (bucket_name, object_name, upload_id, is);
577561  req.SetPartNumber (number);
578-   if  (set_header) {
579-     req.SetTrafficLimitByHeader (StringUtil::Uint64ToString (traffic_limit));
580-   } else  {
581-     req.SetTrafficLimitByParam (StringUtil::Uint64ToString (traffic_limit));
582-   }
562+   req.SetTrafficLimit (traffic_limit);
583563  qcloud_cos::UploadPartDataResp resp;
584564  qcloud_cos::CosResult result = cos.UploadPartData (req, &resp);
585565  *etag = resp.GetEtag ();
@@ -629,7 +609,7 @@ void MultiUploadObject(qcloud_cos::CosAPI& cos, const std::string& bucket_name,
629609  qcloud_cos::MultiPutObjectReq req (bucket_name, object_name, local_file);
630610  req.SetRecvTimeoutInms (1000  * 60 );
631611  qcloud_cos::MultiPutObjectResp resp;
632-   qcloud_cos::CosResult result = cos.PutObject (req, &resp);
612+   qcloud_cos::CosResult result = cos.MultiPutObject (req, &resp);
633613
634614  if  (result.IsSucc ()) {
635615    std::cout << " MultiUpload Succ." 
@@ -667,7 +647,7 @@ void MultiUploadObjectWideChar(qcloud_cos::CosAPI& cos,
667647  req.SetWideCharPath ();  //  需要调用该函数
668648  req.SetRecvTimeoutInms (1000  * 60 );
669649  qcloud_cos::MultiPutObjectResp resp;
670-   qcloud_cos::CosResult result = cos.PutObject (req, &resp);
650+   qcloud_cos::CosResult result = cos.MultiPutObject (req, &resp);
671651
672652  if  (result.IsSucc ()) {
673653    std::cout << " MultiUploadObjectWideChar Succ." 
@@ -692,17 +672,12 @@ void MultiUploadObjectLimitTraffic(qcloud_cos::CosAPI& cos,
692672                                   const  std::string& bucket_name,
693673                                   const  std::string& object_name,
694674                                   const  std::string& local_file,
695-                                    const  uint64_t  traffic_limit,
696-                                    bool  set_header = true ) {
675+                                    const  uint64_t  traffic_limit) {
697676  qcloud_cos::MultiPutObjectReq req (bucket_name, object_name, local_file);
698-   if  (set_header) {
699-     req.SetTrafficLimitByHeader (StringUtil::Uint64ToString (traffic_limit));
700-   } else  {
701-     req.SetTrafficLimitByParam (StringUtil::Uint64ToString (traffic_limit));
702-   }
677+   req.SetTrafficLimit (traffic_limit);
703678  req.SetRecvTimeoutInms (1000  * 60 );
704679  qcloud_cos::MultiPutObjectResp resp;
705-   qcloud_cos::CosResult result = cos.PutObject (req, &resp);
680+   qcloud_cos::CosResult result = cos.MultiPutObject (req, &resp);
706681
707682  if  (result.IsSucc ()) {
708683    std::cout << " MultiUpload Succ." 
@@ -1633,8 +1608,8 @@ static void ResumableGetObject(qcloud_cos::CosAPI& cos,
16331608                               const  std::string& bucket_name,
16341609                               const  std::string& object_name,
16351610                               const  std::string& file_path) {
1636-   qcloud_cos::MultiGetObjectReq  req (bucket_name, object_name, file_path);
1637-   qcloud_cos::MultiGetObjectResp  resp;
1611+   qcloud_cos::GetObjectByFileReq  req (bucket_name, object_name, file_path);
1612+   qcloud_cos::GetObjectByFileResp  resp;
16381613
16391614  CosResult resule = cos.ResumableGetObject (req, &resp);
16401615  if  (resule.IsSucc ()) {
@@ -1662,29 +1637,30 @@ static void ProgressCallback(uint64_t transferred_size, uint64_t total_size,
16621637
16631638static  void  MultiGetObjectAsyncDoneCallback (const  SharedAsyncContext& context,
16641639                                            void * user_data) {
1640+   UNUSED_PARAM (user_data)
16651641  std::cout << " MultiGetObjectAsyncDoneCallback, BucketName:" 
16661642            << context->GetBucketName ()
16671643            << " , ObjectName:" GetObjectName ()
16681644            << " , LocalFile:" GetLocalFilePath () << std::endl;
1669-   //  qcloud_cos::MultiGetObjectReq对应的响应为qcloud_cos::MultiGetObjectResp 
1645+   //  qcloud_cos::MultiGetObjectReq对应的响应为qcloud_cos::GetObjectByFileResp 
16701646  if  (context->GetResult ().IsSucc ()) {
16711647    //  获取响应
1672-     std::cout << " MultiGetObjectAsync  succeed" 
1648+     std::cout << " AsyncMultiGetObject  succeed" 
16731649    std::cout << " Result:" GetResult ().DebugString () << std::endl;
1674-     MultiGetObjectResp  resp = context->GetMultiGetObjectResp ();
1650+     AsyncResp  resp = context->GetAsyncResp ();
16751651    std::cout << " ETag:" GetEtag () << std::endl;
16761652    std::cout << " Crc64:" GetXCosHashCrc64Ecma () << std::endl;
16771653  } else  {
1678-     std::cout << " MultiGetObjectAsync  failed" 
1654+     std::cout << " AsyncMultiGetObject  failed" 
16791655    std::cout << " ErrorMsg:" GetResult ().GetErrorMsg () << std::endl;
16801656  }
16811657}
16821658//   异步下载对象,支持更新下载进度
1683- void  MultiGetObjectAsync (qcloud_cos::CosAPI& cos,
1659+ void  AsyncMultiGetObject (qcloud_cos::CosAPI& cos,
16841660                         const  std::string& bucket_name,
16851661                         const  std::string& object_name,
16861662                         const  std::string& file_path) {
1687-   qcloud_cos::MultiGetObjectReq  req (bucket_name, object_name, file_path);
1663+   qcloud_cos::AsyncMultiGetObjectReq  req (bucket_name, object_name, file_path);
16881664  //  设置进度回调
16891665  req.SetTransferProgressCallback (&ProgressCallback);
16901666  //  设置状态回调
@@ -1693,55 +1669,55 @@ void MultiGetObjectAsync(qcloud_cos::CosAPI& cos,
16931669  req.SetUserData (&req);
16941670
16951671  //  开始下载
1696-   SharedAsyncContext context = cos.GetObjectAsync (req);
1672+   SharedAsyncContext context = cos.AsyncMultiGetObject (req);
16971673
16981674  //  等待下载结束
16991675  context->WaitUntilFinish ();
17001676
17011677  //  检查结果
17021678  if  (context->GetResult ().IsSucc ()) {
17031679    //  获取响应
1704-     std::cout << " MultiGetObjectAsync  succeed" 
1680+     std::cout << " AsyncMultiGetObject  succeed" 
17051681    std::cout << " Result:" GetResult ().DebugString () << std::endl;
1706-     MultiGetObjectResp  resp = context->GetMultiGetObjectResp ();
1682+     AsyncResp  resp = context->GetAsyncResp ();
17071683    std::cout << " ETag:" GetEtag () << std::endl;
17081684    std::cout << " Crc64:" GetXCosHashCrc64Ecma () << std::endl;
17091685  } else  {
1710-     std::cout << " MultiGetObjectAsync  failed" 
1686+     std::cout << " AsyncMultiGetObject  failed" 
17111687    std::cout << " ErrorMsg:" GetResult ().GetErrorMsg () << std::endl;
17121688  }
17131689  std::this_thread::sleep_for (std::chrono::seconds (1 ));
17141690}
17151691
17161692static  void  MultiPutObjectAsyncDoneCallback (const  SharedAsyncContext& context,
17171693                                            void * user_data) {
1694+   UNUSED_PARAM (user_data)
17181695  std::cout << " MultiPutObjectAsyncDoneCallback, BucketName:" 
17191696            << context->GetBucketName ()
17201697            << " , ObjectName:" GetObjectName ()
17211698            << " , LocalFile:" GetLocalFilePath () << std::endl;
1722-   //  qcloud_cos::MultiPutObjectReq对应的响应为qcloud_cos::MultiPutObjectResp
17231699  if  (context->GetResult ().IsSucc ()) {
17241700    //  获取响应
1725-     std::cout << " MultiPutObjectAsync  succeed" 
1701+     std::cout << " AsyncMultiPutObject  succeed" 
17261702    std::cout << " Result:" GetResult ().DebugString () << std::endl;
1727-     MultiPutObjectResp  resp = context->GetMultiPutObjectResp ();
1728-     std::cout << " Location:" GetLocation () << std::endl;
1729-     std::cout << " Bucket:" GetBucket () << std::endl;
1730-     std::cout << " Key:" GetKey () << std::endl;
1703+     AsyncResp  resp = context->GetAsyncResp ();
1704+     // std::cout << "Location:" << resp.GetLocation() << std::endl;
1705+     // std::cout << "Bucket:" << resp.GetBucket() << std::endl;
1706+     // std::cout << "Key:" << resp.GetKey() << std::endl;
17311707    std::cout << " ETag:" GetEtag () << std::endl;
17321708    std::cout << " Crc64:" GetXCosHashCrc64Ecma () << std::endl;
17331709  } else  {
1734-     std::cout << " MultiGetObjectAsync  failed" 
1710+     std::cout << " AsyncMultiGetObject  failed" 
17351711    std::cout << " ErrorMsg:" GetResult ().GetErrorMsg () << std::endl;
17361712  }
17371713}
17381714
17391715//  异步多上传对象,支持更新上传进度
1740- void  MultiPutObjectAsync (qcloud_cos::CosAPI& cos,
1716+ void  AsyncMultiPutObject (qcloud_cos::CosAPI& cos,
17411717                         const  std::string& bucket_name,
17421718                         const  std::string& object_name,
17431719                         const  std::string& local_file) {
1744-   qcloud_cos::MultiPutObjectReq  req (bucket_name, object_name, local_file);
1720+   qcloud_cos::AsyncMultiPutObjectReq  req (bucket_name, object_name, local_file);
17451721  req.SetRecvTimeoutInms (1000  * 60 );
17461722  //  设置上传进度回调
17471723  req.SetTransferProgressCallback (&ProgressCallback);
@@ -1751,7 +1727,7 @@ void MultiPutObjectAsync(qcloud_cos::CosAPI& cos,
17511727  req.SetUserData (&req);
17521728
17531729  //  开始上传
1754-   SharedAsyncContext context = cos.PutObjectAsync (req);
1730+   SharedAsyncContext context = cos.AsyncMultiPutObject (req);
17551731
17561732  //  等待上传结束
17571733  std::cout << " wait finish..." 
@@ -1760,16 +1736,16 @@ void MultiPutObjectAsync(qcloud_cos::CosAPI& cos,
17601736  //  检查结果
17611737  if  (context->GetResult ().IsSucc ()) {
17621738    //  获取响应
1763-     std::cout << " MultiPutObjectAsync  succeed" 
1739+     std::cout << " AsyncMultiPutObject  succeed" 
17641740    std::cout << " Result:" GetResult ().DebugString () << std::endl;
1765-     MultiPutObjectResp  resp = context->GetMultiPutObjectResp ();
1766-     std::cout << " Location:" GetLocation () << std::endl;
1767-     std::cout << " Bucket:" GetBucket () << std::endl;
1768-     std::cout << " Key:" GetKey () << std::endl;
1741+     AsyncResp  resp = context->GetAsyncResp ();
1742+     // std::cout << "Location:" << resp.GetLocation() << std::endl;
1743+     // std::cout << "Bucket:" << resp.GetBucket() << std::endl;
1744+     // std::cout << "Key:" << resp.GetKey() << std::endl;
17691745    std::cout << " ETag:" GetEtag () << std::endl;
17701746    std::cout << " Crc64:" GetXCosHashCrc64Ecma () << std::endl;
17711747  } else  {
1772-     std::cout << " MultiPutObjectAsync  failed" 
1748+     std::cout << " AsyncMultiPutObject  failed" 
17731749    std::cout << " ErrorMsg:" GetResult ().GetErrorMsg () << std::endl;
17741750  }
17751751}
@@ -1926,8 +1902,7 @@ void DeleteObjectsByPrefix(qcloud_cos::CosAPI& cos,
19261902void  MoveObject (qcloud_cos::CosAPI& cos, const  std::string& bucket_name,
19271903                const  std::string& src_object, const  std::string& dst_object) {
19281904  MoveObjectReq req (bucket_name, src_object, dst_object);
1929-   MoveObjectResp resp;
1930-   CosResult result = cos.MoveObject (req, &resp);
1905+   CosResult result = cos.MoveObject (req);
19311906  if  (result.IsSucc ()) {
19321907    std::cout << " MoveObject Succ." 
19331908  } else  {
@@ -2480,6 +2455,8 @@ void TestLogCallback(const std::string& log) {
24802455}
24812456
24822457int  main (int  argc, char ** argv) {
2458+   UNUSED_PARAM (argc)
2459+   UNUSED_PARAM (argv)
24832460  //  config.json中字段的说明,可以参考https://cloud.tencent.com/document/product/436/12301
24842461  qcloud_cos::CosConfig config (" ./config.json" 
24852462  config.SetLogCallback (&TestLogCallback);
@@ -2834,8 +2811,8 @@ int main(int argc, char** argv) {
28342811
28352812  //  async
28362813  // {
2837-   //     MultiPutObjectAsync (cos, bucket_name, "bigfile", "./bigfile");
2838-   //     MultiGetObjectAsync (cos, bucket_name, "bigfile", "./bigfile_download");
2814+   //     AsyncMultiPutObject (cos, bucket_name, "bigfile", "./bigfile");
2815+   //     AsyncMultiGetObject (cos, bucket_name, "bigfile", "./bigfile_download");
28392816  // }
28402817
28412818  // {
0 commit comments