cos_api.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. #ifndef COS_API_H
  2. #define COS_API_H
  3. #include "op/bucket_op.h"
  4. #include "op/cos_result.h"
  5. #include "op/object_op.h"
  6. #include "op/service_op.h"
  7. #include "util/auth_tool.h"
  8. #include "util/codec_util.h"
  9. #include "Poco/TaskManager.h"
  10. namespace qcloud_cos {
  11. class CosAPI {
  12. public:
  13. /// \brief CosAPI构造函数
  14. ///
  15. /// \param config cos配置
  16. explicit CosAPI(CosConfig& config);
  17. ~CosAPI();
  18. /// \brief 设置密钥
  19. void SetCredentail(const std::string& ak, const std::string& sk,
  20. const std::string& token);
  21. /// \brief 获取 Bucket 所在的地域信息
  22. std::string GetBucketLocation(const std::string& bucket_name);
  23. /// \brief 生成一个预签名链接
  24. std::string GeneratePresignedUrl(const GeneratePresignedUrlReq& req);
  25. /// \brief 生成一个预签名链接
  26. std::string GeneratePresignedUrl(const std::string& bucket_name,
  27. const std::string& object_name,
  28. uint64_t start_time_in_s,
  29. uint64_t end_time_in_s,
  30. HTTP_METHOD http_method);
  31. /// \brief 生成一个预签名的GET下载链接
  32. std::string GeneratePresignedUrl(const std::string& bucket_name,
  33. const std::string& object_name,
  34. uint64_t start_time_in_s,
  35. uint64_t end_time_in_s);
  36. /// \brief 判断Bucket是否存在
  37. bool IsBucketExist(const std::string& bucket_name);
  38. /// \brief 判断Object是否存在
  39. bool IsObjectExist(const std::string& bucket_name,
  40. const std::string& object_name);
  41. /// \brief List Buckets
  42. /// 详见: https://cloud.tencent.com/document/api/436/8291
  43. ///
  44. /// \param req GetService请求
  45. /// \param resp GetService响应
  46. ///
  47. /// \return 本次请求的调用情况(如状态码等)
  48. CosResult GetService(const GetServiceReq& req, GetServiceResp* resp);
  49. /// \brief 创建一个Bucket
  50. /// 详见: https://www.qcloud.com/document/product/436/7738
  51. ///
  52. /// \param req PutBucket请求
  53. /// \param resp PutBucket响应
  54. ///
  55. /// \return 本次请求的调用情况(如状态码等)
  56. CosResult PutBucket(const PutBucketReq& req, PutBucketResp* resp);
  57. /// \brief 确认Bucket是否存在
  58. /// (详见:https://cloud.tencent.com/document/product/436/7735)
  59. ///
  60. /// \param req HeadBucket请求
  61. /// \param resp HeadBucket响应
  62. ///
  63. /// \return 本次请求的调用情况(如状态码等)
  64. CosResult HeadBucket(const HeadBucketReq& req, HeadBucketResp* resp);
  65. /// \brief 列出该Bucket下的部分或者全部Object, 需要对Bucket有Read 权限
  66. /// 详见: https://www.qcloud.com/document/product/436/7734
  67. ///
  68. /// \param req GetBucket请求
  69. /// \param resp GetBucket响应
  70. ///
  71. /// \return 返回HTTP请求的状态码及错误信息
  72. CosResult GetBucket(const GetBucketReq& req, GetBucketResp* resp);
  73. CosResult ListMultipartUpload(const ListMultipartUploadReq& req,
  74. ListMultipartUploadResp* resp);
  75. /// \brief 删除Bucket
  76. /// 详见: https://cloud.tencent.com/document/product/436/7732
  77. ///
  78. /// \param req DeleteBucket请求
  79. /// \param resp DeleteBucket响应
  80. ///
  81. /// \return 本次请求的调用情况(如状态码等)
  82. CosResult DeleteBucket(const DeleteBucketReq& req, DeleteBucketResp* resp);
  83. /// \brief 获得存储桶的版本控制信息
  84. /// (详见:https://cloud.tencent.com/document/product/436/8597)
  85. ///
  86. /// \param req GetBucketVersioning请求
  87. /// \param resp GetBucketVersioning返回
  88. ///
  89. /// \return 本次请求的调用情况(如状态码等)
  90. CosResult GetBucketVersioning(const GetBucketVersioningReq& req,
  91. GetBucketVersioningResp* resp);
  92. /// \brief 启用或者暂停存储桶的版本控制功能
  93. /// (详见:https://cloud.tencent.com/document/product/436/8591)
  94. ///
  95. /// \param req PutBucketVersioning请求
  96. /// \param resp PutBucketVersioning返回
  97. ///
  98. /// \return 本次请求的调用情况(如状态码等)
  99. CosResult PutBucketVersioning(const PutBucketVersioningReq& req,
  100. PutBucketVersioningResp* resp);
  101. /// \brief 列出Bucket下的跨域复制配置
  102. ///
  103. /// \param req GetBucketReplication请求
  104. /// \param resp GetBucketReplication返回
  105. ///
  106. /// \return 本次请求的调用情况(如状态码等)
  107. CosResult GetBucketReplication(const GetBucketReplicationReq& req,
  108. GetBucketReplicationResp* resp);
  109. /// \brief 增加/替换Bucket下的跨域复制配置
  110. ///
  111. /// \param req PutBucketReplication请求
  112. /// \param resp PutBucketReplication返回
  113. ///
  114. /// \return 本次请求的调用情况(如状态码等)
  115. CosResult PutBucketReplication(const PutBucketReplicationReq& req,
  116. PutBucketReplicationResp* resp);
  117. /// \brief 删除Bucket下的跨域复制配置
  118. ///
  119. /// \param req DeleteBucketReplication请求
  120. /// \param resp DeleteBucketReplication返回
  121. ///
  122. /// \return 本次请求的调用情况(如状态码等)
  123. CosResult DeleteBucketReplication(const DeleteBucketReplicationReq& req,
  124. DeleteBucketReplicationResp* resp);
  125. /// \brief 列出Bucket下的生命周期配置
  126. ///
  127. /// \param req GetBucketLifecycle请求
  128. /// \param resp GetBucketLifecycle返回
  129. ///
  130. /// \return 本次请求的调用情况(如状态码等)
  131. CosResult GetBucketLifecycle(const GetBucketLifecycleReq& req,
  132. GetBucketLifecycleResp* resp);
  133. /// \brief 增加/替换Bucket下的生命周期配置
  134. ///
  135. /// \param req PutBucketLifecycle请求
  136. /// \param resp PutBucketLifecycle返回
  137. ///
  138. /// \return 本次请求的调用情况(如状态码等)
  139. CosResult PutBucketLifecycle(const PutBucketLifecycleReq& req,
  140. PutBucketLifecycleResp* resp);
  141. /// \brief 删除Bucket下的生命周期配置
  142. ///
  143. /// \param req DeleteBucketLifecycle请求
  144. /// \param resp DeleteBucketLifecycle返回
  145. ///
  146. /// \return 本次请求的调用情况(如状态码等)
  147. CosResult DeleteBucketLifecycle(const DeleteBucketLifecycleReq& req,
  148. DeleteBucketLifecycleResp* resp);
  149. /// \brief 列出Bucket下的ACL
  150. ///
  151. /// \param req GetBucketACL请求
  152. /// \param resp GetBucketACL返回
  153. ///
  154. /// \return 本次请求的调用情况(如状态码等)
  155. CosResult GetBucketACL(const GetBucketACLReq& req, GetBucketACLResp* resp);
  156. /// \brief 增加/替换Bucket下的ACL, 可以通过Header或者Body传入ACL信息
  157. /// 注意Header 和 Body 只能选择其中一种,否则响应返回会冲突
  158. ///
  159. /// \param req PutBucketACL请求
  160. /// \param resp PutBucketACL返回
  161. ///
  162. /// \return 本次请求的调用情况(如状态码等)
  163. CosResult PutBucketACL(const PutBucketACLReq& req, PutBucketACLResp* resp);
  164. /// \brief 获取Bucket的权限策略
  165. ///
  166. /// \param req GetBucketPolicy请求
  167. /// \param resp GetBucketPolicy返回
  168. ///
  169. /// \return 本次请求的调用情况(如状态码等)
  170. CosResult GetBucketPolicy(const GetBucketPolicyReq& req, GetBucketPolicyResp* resp);
  171. /// \brief 写入/替换Bucket的权限策略,通过Body传入
  172. ///
  173. /// \param req PutBucketPolicy请求
  174. /// \param resp PutBucketPolicy返回
  175. ///
  176. /// \return 本次请求的调用情况(如状态码等)
  177. CosResult PutBucketPolicy(const PutBucketPolicyReq& req, PutBucketPolicyResp* resp);
  178. /// \brief 删除Bucket的权限策略
  179. ///
  180. /// \param req DeleteBucketPolicy请求
  181. /// \param resp DeleteBucketPolicy返回
  182. ///
  183. /// \return 本次请求的调用情况(如状态码等)
  184. CosResult DeleteBucketPolicy(const DeleteBucketPolicyReq& req, DeleteBucketPolicyResp* resp);
  185. /// \brief 列出Bucket下的CORS
  186. ///
  187. /// \param req GetBucketCORS请求
  188. /// \param resp GetBucketCORS返回
  189. ///
  190. /// \return 本次请求的调用情况(如状态码等)
  191. CosResult GetBucketCORS(const GetBucketCORSReq& req, GetBucketCORSResp* resp);
  192. /// \brief 增加/替换Bucket下的CORS
  193. ///
  194. /// \param req PutBucketCORS请求
  195. /// \param resp PutBucketCORS返回
  196. ///
  197. /// \return 本次请求的调用情况(如状态码等)
  198. CosResult PutBucketCORS(const PutBucketCORSReq& req, PutBucketCORSResp* resp);
  199. /// \brief 删除Bucket下的CORS
  200. ///
  201. /// \param req DeleteBucketCORS请求
  202. /// \param resp DeleteBucketCORS返回
  203. ///
  204. /// \return 本次请求的调用情况(如状态码等)
  205. CosResult DeleteBucketCORS(const DeleteBucketCORSReq& req,
  206. DeleteBucketCORSResp* resp);
  207. /// \brief 为存储桶设置 Referer 白名单或者黑名单
  208. ///
  209. /// \param req PutBucketReferer请求
  210. /// \param resp PutBucketReferer响应
  211. ///
  212. /// \return 本次请求的调用情况(如状态码等)
  213. CosResult PutBucketReferer(const PutBucketRefererReq& req,
  214. PutBucketRefererResp* resp);
  215. /// \brief 为存储桶设置 Referer 白名单或者黑名单
  216. ///
  217. /// \param req GetBucketReferer请求
  218. /// \param resp GetBucketReferer响应
  219. ///
  220. /// \return 本次请求的调用情况(如状态码等)
  221. CosResult GetBucketReferer(const GetBucketRefererReq& req,
  222. GetBucketRefererResp* resp);
  223. /// \brief 设置源存储桶的日志配置信息。
  224. ///
  225. /// \param req PutBucketLogging请求
  226. /// \param resp PutBucketLogging返回
  227. ///
  228. /// \return 本次请求的调用情况(如状态码等)
  229. CosResult PutBucketLogging(const PutBucketLoggingReq& req,
  230. PutBucketLoggingResp* resp);
  231. /// \brief 获取源存储桶的日志配置信息。
  232. ///
  233. /// \param req GetBucketLogging请求
  234. /// \param resp GetBucketLogging返回
  235. ///
  236. /// \return 本次请求的调用情况(如状态码等)
  237. CosResult GetBucketLogging(const GetBucketLoggingReq& req,
  238. GetBucketLoggingResp* resp);
  239. /// \brief 设置存储桶自定义域名。
  240. ///
  241. /// \param req PutBucketDomain请求
  242. /// \param resp PutBucketDomain返回
  243. ///
  244. /// \return 本次请求的调用情况(如状态码等)
  245. CosResult PutBucketDomain(const PutBucketDomainReq& req,
  246. PutBucketDomainResp* resp);
  247. /// \brief 获取存储桶自定义域名。
  248. ///
  249. /// \param req GetBucketDomain请求
  250. /// \param resp GetBucketDomain返回
  251. ///
  252. /// \return 本次请求的调用情况(如状态码等)
  253. CosResult GetBucketDomain(const GetBucketDomainReq& req,
  254. GetBucketDomainResp* resp);
  255. /// \brief 为存储桶配置静态网站,可以通过传入 XML
  256. /// 格式的配置文件进行配置,文件大小限制为64KB.
  257. ///
  258. /// \param req PutBucketWebsite请求
  259. /// \param resp PutBucketWebsite返回
  260. ///
  261. /// \return 本次请求的调用情况(如状态码等)
  262. CosResult PutBucketWebsite(const PutBucketWebsiteReq& req,
  263. PutBucketWebsiteResp* resp);
  264. /// \brief 请求用于获取与存储桶关联的静态网站配置信息.
  265. ///
  266. /// \param req GetBucketWebsite请求
  267. /// \param resp GetBucketWebsite返回
  268. ///
  269. /// \return 本次请求的调用情况(如状态码等)
  270. CosResult GetBucketWebsite(const GetBucketWebsiteReq& req,
  271. GetBucketWebsiteResp* resp);
  272. /// \brief 删除存储桶中的静态网站配置.
  273. ///
  274. /// \param req DeleteBucketWebsite请求
  275. /// \param resp DeleteBucketWebsite返回
  276. ///
  277. /// \return 本次请求的调用情况(如状态码等)
  278. CosResult DeleteBucketWebsite(const DeleteBucketWebsiteReq& req,
  279. DeleteBucketWebsiteResp* resp);
  280. /// \brief 已存在的Bucket设置标签.
  281. ///
  282. /// \param req PutBucketTagging请求
  283. /// \param resp PutBucketTagging返回
  284. ///
  285. /// \return 本次请求的调用情况(如状态码等)
  286. CosResult PutBucketTagging(const PutBucketTaggingReq& req,
  287. PutBucketTaggingResp* resp);
  288. /// \brief 查询指定存储桶下已有的存储桶标签.
  289. ///
  290. /// \param req GetBucketTagging请求
  291. /// \param resp GetBucketTagging返回
  292. ///
  293. /// \return 本次请求的调用情况(如状态码等)
  294. CosResult GetBucketTagging(const GetBucketTaggingReq& req,
  295. GetBucketTaggingResp* resp);
  296. /// \brief 删除指定存储桶下已有的存储桶标签.
  297. ///
  298. /// \param req DeleteBucketTagging请求
  299. /// \param resp DeleteBucketTagging返回
  300. ///
  301. /// \return 本次请求的调用情况(如状态码等)
  302. CosResult DeleteBucketTagging(const DeleteBucketTaggingReq& req,
  303. DeleteBucketTaggingResp* resp);
  304. /// \brief 在存储桶中创建清单任务.
  305. ///
  306. /// \param req PutBucketInventory请求
  307. /// \param resp PutBucketInventory返回
  308. ///
  309. /// \return 本次请求的调用情况(如状态码等)
  310. CosResult PutBucketInventory(const PutBucketInventoryReq& req,
  311. PutBucketInventoryResp* resp);
  312. /// \brief 用于查询存储桶中用户的清单任务信息.
  313. ///
  314. /// \param req GetBucketInventory请求
  315. /// \param resp GetBucketInventory返回
  316. ///
  317. /// \return 本次请求的调用情况(如状态码等)
  318. CosResult GetBucketInventory(const GetBucketInventoryReq& req,
  319. GetBucketInventoryResp* resp);
  320. /// \brief 用于请求返回一个存储桶中的所有清单任务.
  321. ///
  322. /// \param req ListBucketInventoryConfigurations请求
  323. /// \param resp ListBucketInventoryConfigurations返回
  324. ///
  325. /// \return 本次请求的调用情况(如状态码等)
  326. CosResult ListBucketInventoryConfigurations(
  327. const ListBucketInventoryConfigurationsReq& req,
  328. ListBucketInventoryConfigurationsResp* resp);
  329. /// \brief 用于删除存储桶中指定的清单任务.
  330. ///
  331. /// \param req DeleteBucketinventory请求
  332. /// \param resp DeleteBucketinventory返回
  333. ///
  334. /// \return 本次请求的调用情况(如状态码等)
  335. CosResult DeleteBucketInventory(const DeleteBucketInventoryReq& req,
  336. DeleteBucketInventoryResp* resp);
  337. /// \brief 获取对应Object的meta信息数据
  338. /// 详见: https://www.qcloud.com/document/product/436/7745
  339. ///
  340. /// \param req HeadObject请求
  341. /// \param resp HeadObject响应
  342. ///
  343. /// \return 返回HTTP请求的状态码及错误信息
  344. CosResult HeadObject(const HeadObjectReq& req, HeadObjectResp* resp);
  345. /// \brief 下载Bucket中的一个文件至流中
  346. /// 详见: https://www.qcloud.com/document/product/436/7753
  347. ///
  348. /// \param req GetObjectByStream请求
  349. /// \param resp GetObjectByStream返回
  350. ///
  351. /// \return 返回HTTP请求的状态码及错误信息
  352. CosResult GetObject(const GetObjectByStreamReq& req,
  353. GetObjectByStreamResp* resp);
  354. /// \brief 下载Bucket中的一个文件到本地
  355. /// 详见: https://www.qcloud.com/document/product/436/7753
  356. ///
  357. /// \param req GetObjectByFile请求
  358. /// \param resp GetObjectByFile返回
  359. ///
  360. /// \return 返回HTTP请求的状态码及错误信息
  361. CosResult GetObject(const GetObjectByFileReq& req, GetObjectByFileResp* resp);
  362. /// \brief 返回对象的URL
  363. ///
  364. /// \param bucket 存储桶名
  365. /// \param object 对象名
  366. /// \param https 是否使用https
  367. /// \param region 地域名,默认使用配置文件中的地域名
  368. ///
  369. /// \return 返回HTTP请求的状态码及错误信息
  370. std::string GetObjectUrl(const std::string& bucket, const std::string& object,
  371. bool https = true, const std::string& region = "");
  372. /// \brief 将本地的文件上传至指定Bucket中
  373. /// 详见: https://www.qcloud.com/document/product/436/7749
  374. ///
  375. /// \param req PutObject请求
  376. /// \param resp PutObject响应
  377. ///
  378. /// \return 返回HTTP请求的状态码及错误信息
  379. CosResult PutObject(const PutObjectByFileReq& req, PutObjectByFileResp* resp);
  380. /// \brief 将指定流上传至指定Bucket中
  381. /// 详见: https://www.qcloud.com/document/product/436/7749
  382. ///
  383. /// \param req PutObject请求
  384. /// \param resp PutObject响应
  385. ///
  386. /// \return 返回HTTP请求的状态码及错误信息
  387. CosResult PutObject(const PutObjectByStreamReq& req,
  388. PutObjectByStreamResp* resp);
  389. /// \brief 删除Object
  390. /// 详见: https://cloud.tencent.com/document/product/436/7743
  391. ///
  392. /// \param req DeleteObject请求
  393. /// \param resp DeleteObject响应
  394. ///
  395. /// \return 本次请求的调用情况(如状态码等)
  396. CosResult DeleteObject(const DeleteObjectReq& req, DeleteObjectResp* resp);
  397. /// \brief 批量删除Object
  398. ///
  399. /// \param req DeleteObjects请求
  400. /// \param resp DeleteObjects返回
  401. ///
  402. /// \return 本次请求的调用情况(如状态码等)
  403. CosResult DeleteObjects(const DeleteObjectsReq& req, DeleteObjectsResp* resp);
  404. /// \brief
  405. /// 请求实现初始化分片上传,成功执行此请求以后会返回UploadId用于后续的Upload
  406. /// Part请求
  407. /// 详见: https://www.qcloud.com/document/product/436/7746
  408. ///
  409. /// \param req InitMultiUpload请求
  410. /// \param resp InitMultiUpload返回
  411. ///
  412. /// \return 返回HTTP请求的状态码及错误信息
  413. CosResult InitMultiUpload(const InitMultiUploadReq& req,
  414. InitMultiUploadResp* resp);
  415. /// \brief
  416. /// 初始化以后的分片上传,支持的分片的数量为1到10000,片的大小为1MB到5GB
  417. /// 详见: https://www.qcloud.com/document/product/436/7750
  418. ///
  419. /// \param req UploadPartData请求
  420. /// \param resp UploadPartData返回
  421. ///
  422. /// \return 返回HTTP请求的状态码及错误信息
  423. CosResult UploadPartData(const UploadPartDataReq& req,
  424. UploadPartDataResp* resp);
  425. /// \brief
  426. /// 初始化以后的分片上传复制,支持的片的数量为1到10000,片的大小为1MB到5GB
  427. /// 详见: https://cloud.tencent.com/document/product/436/8287
  428. ///
  429. /// \param req UploadPartCopyData请求
  430. /// \param resp UploadPartCopyData返回
  431. ///
  432. /// \return 返回HTTP请求的状态码及错误信息
  433. CosResult UploadPartCopyData(const UploadPartCopyDataReq& req,
  434. UploadPartCopyDataResp* resp);
  435. /// \brief 完成整个分块上传。当使用 Upload Parts 上传完所有块以后,
  436. /// 必须调用该 API 来完成整个文件的分块上传
  437. /// 详见: https://www.qcloud.com/document/product/436/7742
  438. ///
  439. /// \param req CompleteMultiUpload请求
  440. /// \param resp CompleteMultiUpload返回
  441. ///
  442. /// \return 返回HTTP请求的状态码及错误信息
  443. CosResult CompleteMultiUpload(const CompleteMultiUploadReq& req,
  444. CompleteMultiUploadResp* resp);
  445. /// \brief 舍弃一个分块上传并删除已上传的块
  446. /// 详见: https://www.qcloud.com/document/product/436/7740
  447. ///
  448. /// \param req AbortMultiUpload请求
  449. /// \param resp AbortMultiUpload返回
  450. ///
  451. /// \return 返回HTTP请求的状态码及错误信息
  452. CosResult AbortMultiUpload(const AbortMultiUploadReq& req,
  453. AbortMultiUploadResp* resp);
  454. /// \brief 查询特定分块上传中的已上传的块
  455. ///
  456. /// \param req ListParts请求
  457. /// \param resp ListParts返回
  458. ///
  459. /// \return
  460. CosResult ListParts(const ListPartsReq& req, ListPartsResp* resp);
  461. /// \brief 列出Object下的ACL
  462. ///
  463. /// \param req GetObjectACL请求
  464. /// \param resp GetObjectACL返回
  465. ///
  466. /// \return 本次请求的调用情况(如状态码等)
  467. CosResult GetObjectACL(const GetObjectACLReq& req, GetObjectACLResp* resp);
  468. /// \brief 增加/替换Object下的ACL, 可以通过Header或者Body传入ACL信息
  469. /// 注意Header 和 Body 只能选择其中一种,否则响应返回会冲突
  470. ///
  471. /// \param req PutObjectACL请求
  472. /// \param resp PutObjectACL返回
  473. ///
  474. /// \return 本次请求的调用情况(如状态码等)
  475. CosResult PutObjectACL(const PutObjectACLReq& req, PutObjectACLResp* resp);
  476. /// \brief 复制Object, 适用于跨园区且Object小于5G
  477. ///
  478. /// \param req PutObjectCopy请求
  479. /// \param resp PutObjectCopy返回
  480. ///
  481. /// \return 本次请求的调用情况(如状态码等)
  482. CosResult PutObjectCopy(const PutObjectCopyReq& req, PutObjectCopyResp* resp);
  483. /// \brief 复制Object,
  484. /// 自动判断源Object大小,调用PutObjectCopy/UploadPartCopyData
  485. ///
  486. /// \param req Copy请求
  487. /// \param resp Copy返回
  488. ///
  489. /// \return 本次请求的调用情况(如状态码等)
  490. CosResult Copy(const CopyReq& req, CopyResp* resp);
  491. /// \brief 对一个通过 COS 归档为 archive 类型的对象进行恢复
  492. ///
  493. /// \param req PostObjectRestore请求
  494. /// \param resp PostObjectRestore返回
  495. ///
  496. /// \return 返回HTTP请求的状态码及错误信息
  497. CosResult PostObjectRestore(const PostObjectRestoreReq& req,
  498. PostObjectRestoreResp* resp);
  499. /// \brief
  500. /// 实现Object跨域访问请求的预请求,参考https://cloud.tencent.com/document/product/436/8288
  501. ///
  502. /// \param req OptionsObjectReq 请求
  503. /// \param resp OptionsObjectResp 响应
  504. ///
  505. /// \return 本次请求的调用情况(如状态码等)
  506. CosResult OptionsObject(const OptionsObjectReq& req, OptionsObjectResp* resp);
  507. /// \brief 支持SELECT
  508. /// 接口,参考https://cloud.tencent.com/document/product/436/37641
  509. CosResult SelectObjectContent(const SelectObjectContentReq& req,
  510. SelectObjectContentResp* resp);
  511. /// \brief 追加对象, 参考https://cloud.tencent.com/document/product/436/7743
  512. ///
  513. /// \param req AppendObject请求
  514. /// \param resp AppendObject响应
  515. ///
  516. /// \return 本次请求的调用情况(如状态码等)
  517. CosResult AppendObject(const AppendObjectReq& req, AppendObjectResp* resp);
  518. /// \brief 列出Bucket下的部分或者全部Object(包括多版本)
  519. ///
  520. /// \param req GetBucketObjectVersions请求
  521. /// \param resp GetBucketObjectVersions响应
  522. ///
  523. /// \return 本次请求的调用情况(如状态码等)
  524. CosResult GetBucketObjectVersions(const GetBucketObjectVersionsReq& req,
  525. GetBucketObjectVersionsResp* resp);
  526. /// \brief 创建推流通道
  527. ///
  528. /// \param req PutLiveChannelReq请求
  529. /// \param resp PutLiveChannelResp响应
  530. ///
  531. /// \return 本次请求的调用情况(如状态码等)
  532. CosResult PutLiveChannel(const PutLiveChannelReq& req,
  533. PutLiveChannelResp* resp);
  534. /// \brief 生成推流通道带签名的推流url
  535. ///
  536. /// \param bucket 存储桶名称
  537. /// \param channel 通道名
  538. /// \param expire 签名过期时间
  539. /// \param url_params url参数
  540. ///
  541. /// \return 带签名的推流url
  542. std::string
  543. GetRtmpSignedPublishUrl(const std::string& bucket, const std::string& channel,
  544. int expire,
  545. const std::map<std::string, std::string> url_params);
  546. /// \brief 启用或者禁用直播通道
  547. ///
  548. /// \param req PutLiveChannelSwitch请求
  549. /// \param resp PutLiveChannelSwitch响应
  550. ///
  551. /// \return 本次请求的调用情况(如状态码等)
  552. CosResult PutLiveChannelSwitch(const PutLiveChannelSwitchReq& req,
  553. PutLiveChannelSwitchResp* resp);
  554. /// \brief 获取直播通道配置信息
  555. ///
  556. /// \param req GetLiveChannel请求
  557. /// \param resp GetLiveChannel响应
  558. ///
  559. /// \return 本次请求的调用情况(如状态码等)
  560. CosResult GetLiveChannel(const GetLiveChannelReq& req,
  561. GetLiveChannelResp* resp);
  562. /// \brief 获取直播通道推流历史
  563. ///
  564. /// \param req GetLiveChannelHistory请求
  565. /// \param resp GetLiveChannelHistory响应
  566. ///
  567. /// \return 本次请求的调用情况(如状态码等)
  568. CosResult GetLiveChannelHistory(const GetLiveChannelHistoryReq& req,
  569. GetLiveChannelHistoryResp* resp);
  570. /// \brief 获取直播通道推流状态
  571. ///
  572. /// \param req GetLiveChannelStatus请求
  573. /// \param resp GetLiveChannelStatus响应
  574. ///
  575. /// \return 本次请求的调用情况(如状态码等)
  576. CosResult GetLiveChannelStatus(const GetLiveChannelStatusReq& req,
  577. GetLiveChannelStatusResp* resp);
  578. /// \brief 删除直播通道
  579. ///
  580. /// \param req GetLiveChannelStatus请求
  581. /// \param resp GetLiveChannelStatus响应
  582. ///
  583. /// \return 本次请求的调用情况(如状态码等)
  584. CosResult DeleteLiveChannel(const DeleteLiveChannelReq& req,
  585. DeleteLiveChannelResp* resp);
  586. /// \brief 查询指定通道在指定时间段推流生成的播放列表
  587. ///
  588. /// \param req GetLiveChannelVodPlaylist请求
  589. /// \param resp GetLiveChannelVodPlaylist响应
  590. ///
  591. /// \return 本次请求的调用情况(如状态码等)
  592. CosResult GetLiveChannelVodPlaylist(const GetLiveChannelVodPlaylistReq& req,
  593. GetLiveChannelVodPlaylistResp* resp);
  594. /// \brief 为指定通道生成一个可供点播例用的播放列
  595. ///
  596. /// \param req PostLiveChannelVodPlaylist请求
  597. /// \param resp PostLiveChannelVodPlaylist响应
  598. ///
  599. /// \return 本次请求的调用情况(如状态码等)
  600. CosResult PostLiveChannelVodPlaylist(const PostLiveChannelVodPlaylistReq& req,
  601. PostLiveChannelVodPlaylistResp* resp);
  602. /// \brief 列举通道
  603. ///
  604. /// \param req PostLiveChannelVodPlaylist请求
  605. /// \param resp PostLiveChannelVodPlaylist响应
  606. ///
  607. /// \return 本次请求的调用情况(如状态码等)
  608. CosResult ListLiveChannel(const ListLiveChannelReq& req,
  609. ListLiveChannelResp* resp);
  610. /// \brief 配置存储桶智能分层
  611. ///
  612. /// \param req PutBucketIntelligentTiering请求
  613. /// \param resp PutBucketIntelligentTiering响应
  614. ///
  615. /// \return 本次请求的调用情况(如状态码等)
  616. CosResult
  617. PutBucketIntelligentTiering(const PutBucketIntelligentTieringReq& req,
  618. PutBucketIntelligentTieringResp* resp);
  619. /// \brief 获取存储桶智能分层配置
  620. ///
  621. /// \param req GetBucketIntelligentTiering请求
  622. /// \param resp GetBucketIntelligentTiering响应
  623. ///
  624. /// \return 本次请求的调用情况(如状态码等)
  625. CosResult
  626. GetBucketIntelligentTiering(const GetBucketIntelligentTieringReq& req,
  627. GetBucketIntelligentTieringResp* resp);
  628. /* Multithread接口 */
  629. /// \brief 封装了初始化分块上传、分块上传、完成分块上传三步,支持断点续传
  630. ///
  631. /// \param req MultiPutObject请求
  632. /// \param resp MultiPutObject响应
  633. ///
  634. /// \return 返回HTTP请求的状态码及错误信息
  635. CosResult MultiPutObject(const MultiPutObjectReq& req,
  636. MultiPutObjectResp* resp);
  637. /// \brief 多线程Range下载对象到本地
  638. /// 详见: https://www.qcloud.com/document/product/436/7753
  639. ///
  640. /// \param req MultiGetObject请求
  641. /// \param resp MultiGetObject响应
  642. ///
  643. /// \return 返回HTTP请求的状态码及错误信息
  644. CosResult MultiGetObject(const MultiGetObjectReq& req,
  645. MultiGetObjectResp* resp);
  646. /* Resumable接口 */
  647. /// \brief 封装了初始化分块上传、分块上传、完成分块上传三步,支持断点续传
  648. // CosResult ResumablePutObject(const PutObjectByFile& req,
  649. // MultiPutObjectResp* resp);
  650. /// \brief 支持断点下载
  651. CosResult ResumableGetObject(const GetObjectByFileReq& req,
  652. GetObjectByFileResp* resp);
  653. /* Async接口 */
  654. /// \brief 异步简单上传本地文件,不支持断点续传
  655. /// \param req PutObjectAsync请求
  656. /// \return 返回context
  657. SharedAsyncContext AsyncPutObject(const AsyncPutObjectReq& req);
  658. SharedAsyncContext AsyncPutObject(const AsyncPutObjectReq& req, Poco::TaskManager*& taskManager);
  659. SharedAsyncContext AsyncPutObject(const AsyncPutObjectByStreamReq& req);
  660. SharedAsyncContext AsyncPutObject(const AsyncPutObjectByStreamReq& req, Poco::TaskManager*& taskManager);
  661. /// \brief
  662. /// 异步上传对象,封装了初始化分块上传、分块上传、完成分块上传三步,支持断点续传
  663. /// \param req MultiPutObjectAsync请求
  664. /// \return 返回context
  665. SharedAsyncContext AsyncMultiPutObject(const AsyncMultiPutObjectReq& req);
  666. SharedAsyncContext AsyncMultiPutObject(const AsyncMultiPutObjectReq& req, Poco::TaskManager*& taskManager);
  667. /// \brief 异步单线程下载对象到本地
  668. /// \param req GetObjectAsync请求
  669. /// \return 返回context
  670. SharedAsyncContext AsyncGetObject(const AsyncGetObjectReq& req);
  671. SharedAsyncContext AsyncGetObject(const AsyncGetObjectReq& req, Poco::TaskManager*& taskManager);
  672. /// \brief 异步多线程下载对象到本地,支持断点续传
  673. /// \param req AsyncResumableGetObject
  674. /// \return 返回context
  675. SharedAsyncContext AsyncResumableGetObject(const AsyncGetObjectReq& req);
  676. SharedAsyncContext AsyncResumableGetObject(const AsyncGetObjectReq& req, Poco::TaskManager*& taskManager);;
  677. /// \brief 异步多线程下载对象到本地
  678. /// \param req MultiGetObjectAsync请求
  679. /// \return 返回context
  680. SharedAsyncContext AsyncMultiGetObject(const AsyncMultiGetObjectReq& req);
  681. SharedAsyncContext AsyncMultiGetObject(const AsyncMultiGetObjectReq& req, Poco::TaskManager*& taskManager);
  682. /* 批量及目录操作接口 */
  683. /// \brief 批量上传对象
  684. /// \param req PutObjects请求
  685. /// \param resp PutObjects响应
  686. /// \return 批量上传结果
  687. CosResult PutObjects(const PutObjectsByDirectoryReq& req,
  688. PutObjectsByDirectoryResp* resp);
  689. /// \brief 创建目录
  690. /// \param req PutDirectory请求
  691. /// \param resp PutDirectory响应
  692. /// \return 创建目录结果
  693. CosResult PutDirectory(const PutDirectoryReq& req, PutDirectoryResp* resp);
  694. /// \brief 移动对象
  695. /// \param req MoveObject请求
  696. /// \return 移动对象结果
  697. CosResult MoveObject(const MoveObjectReq& req);
  698. /// \brief 按前缀删除Object
  699. /// \param req DeleteObjectsByPrefix请求
  700. /// \param resp DeleteObjectsByPrefix响应
  701. /// \return 本次请求的调用情况(如状态码等)
  702. CosResult DeleteObjects(const DeleteObjectsByPrefixReq& req,
  703. DeleteObjectsByPrefixResp* resp);
  704. /* 数据处理接口 */
  705. /*** 存储桶绑定万象服务 ***/
  706. CosResult PutBucketToCI(const PutBucketToCIReq& req,
  707. PutBucketToCIResp* resp);
  708. /** 基础图片处理 **/
  709. /** 图片持久化处理 **/
  710. /*** 上传时处理 ***/
  711. CosResult PutImage(PutImageByFileReq& req, PutImageByFileResp* resp);
  712. /*** 云上数据处理 ***/
  713. CosResult CloudImageProcess(const CloudImageProcessReq& req,
  714. CloudImageProcessResp* resp);
  715. /*** 下载图片时识别二维码 ***/
  716. CosResult GetQRcode(const GetQRcodeReq& req, GetQRcodeResp* resp);
  717. /** 文档处理接口 **/
  718. /*** 查询已经开通文档预览功能的 Bucket ***/
  719. // https://cloud.tencent.com/document/product/436/54057
  720. CosResult DescribeDocProcessBuckets(const DescribeDocProcessBucketsReq& req,
  721. DescribeDocProcessBucketsResp* resp);
  722. /*** 预览文档 ***/
  723. // https://cloud.tencent.com/document/product/436/54058
  724. CosResult DocPreview(const DocPreviewReq& req, DocPreviewResp* resp);
  725. /*** 存储桶绑定文档预览 ***/
  726. CosResult CreateDocBucket(const CreateDocBucketReq& req,
  727. CreateDocBucketResp* resp);
  728. /*** 提交一个文档预览任务 ***/
  729. // https://cloud.tencent.com/document/product/436/54056
  730. CosResult CreateDocProcessJobs(const CreateDocProcessJobsReq& req,
  731. CreateDocProcessJobsResp* resp);
  732. /*** 查询指定的文档预览任务 ***/
  733. // https://cloud.tencent.com/document/product/436/54095
  734. CosResult DescribeDocProcessJob(const DescribeDocProcessJobReq& req,
  735. DescribeDocProcessJobResp* resp);
  736. /*** 拉取符合条件的文档预览任务 ***/
  737. // https://cloud.tencent.com/document/product/436/54096
  738. CosResult DescribeDocProcessJobs(const DescribeDocProcessJobsReq& req,
  739. DescribeDocProcessJobsResp* resp);
  740. /*** 查询文档预览队列 ***/
  741. // https://cloud.tencent.com/document/product/436/54055
  742. CosResult DescribeDocProcessQueues(const DescribeDocProcessQueuesReq& req,
  743. DescribeDocProcessQueuesResp* resp);
  744. /*** 更新文档预览队列 ***/
  745. // https://cloud.tencent.com/document/product/436/54094
  746. CosResult UpdateDocProcessQueue(const UpdateDocProcessQueueReq& req,
  747. UpdateDocProcessQueueResp* resp);
  748. /** 媒体处理接口 **/
  749. /*** 查询已经开通媒体处理功能的存储桶 ***/
  750. // https://cloud.tencent.com/document/product/436/48988
  751. CosResult DescribeMediaBuckets(const DescribeMediaBucketsReq& req,
  752. DescribeMediaBucketsResp* resp);
  753. /*** 存储桶绑定媒体处理 ***/
  754. CosResult CreateMediaBucket(const CreateMediaBucketReq& req,
  755. CreateMediaBucketResp* resp);
  756. /*** 获取媒体文件某个时间的截图 ***/
  757. // https://cloud.tencent.com/document/product/436/55671
  758. CosResult GetSnapshot(const GetSnapshotReq& req, GetSnapshotResp* resp);
  759. /*** 获取媒体文件的信息 ***/
  760. // https://cloud.tencent.com/document/product/436/55672
  761. CosResult GetMediaInfo(const GetMediaInfoReq& req, GetMediaInfoResp* resp);
  762. /*** 获取私有 M3U8 ts 资源的下载授权 ***/
  763. // https://cloud.tencent.com/document/product/436/63740
  764. CosResult GetPm3u8(const GetPm3u8Req& req, GetPm3u8Resp* resp);
  765. /*** 查询媒体处理队列 ***/
  766. // https://cloud.tencent.com/document/product/436/54045
  767. CosResult DescribeMediaQueues(const DescribeMediaQueuesReq& req,
  768. DescribeQueuesResp* resp);
  769. /*** 更新媒体处理队列 ***/
  770. // https://cloud.tencent.com/document/product/436/54046
  771. CosResult UpdateMediaQueue(const UpdateMediaQueueReq& req,
  772. UpdateQueueResp* resp);
  773. /* 异步任务接口 */
  774. /** 创建异步任务 **/
  775. CosResult CreateDataProcessJobs(const CreateDataProcessJobsReq& req,
  776. CreateDataProcessJobsResp* resp);
  777. /** 查询异步任务 **/
  778. CosResult DescribeDataProcessJob(const DescribeDataProcessJobReq& req,
  779. DescribeDataProcessJobResp* resp);
  780. /** 取消异步任务 **/
  781. CosResult CancelDataProcessJob(const CancelDataProcessJobReq& req,
  782. CancelDataProcessJobResp* resp);
  783. /* 内容审核接口 */
  784. /** 图片审核 **/
  785. /*** 图片同步审核 ***/
  786. // https://cloud.tencent.com/document/product/436/45434
  787. CosResult GetImageAuditing(const GetImageAuditingReq& req,
  788. GetImageAuditingResp* resp);
  789. /*** 图片批量审核 ***/
  790. // https://cloud.tencent.com/document/product/436/63593
  791. CosResult BatchImageAuditing(const BatchImageAuditingReq& req,
  792. BatchImageAuditingResp* resp);
  793. /*** 查询图片审核任务结果 ***/
  794. // https://cloud.tencent.com/document/product/436/68904
  795. CosResult DescribeImageAuditingJob(const DescribeImageAuditingJobReq& req,
  796. DescribeImageAuditingJobResp* resp);
  797. /*** 提交视频审核任务 ***/
  798. // https://cloud.tencent.com/document/product/436/47316
  799. CosResult CreateVideoAuditingJob(const CreateVideoAuditingJobReq& req,
  800. CreateVideoAuditingJobResp* resp);
  801. /*** 查询视频审核任务结果 ***/
  802. // https://cloud.tencent.com/document/product/436/47317
  803. CosResult DescribeVideoAuditingJob(const DescribeVideoAuditingJobReq& req,
  804. DescribeVideoAuditingJobResp* resp);
  805. /*** 提交音频审核任务 ***/
  806. // https://cloud.tencent.com/document/product/436/54063
  807. CosResult CreateAudioAuditingJob(const CreateAudioAuditingJobReq& req,
  808. CreateAudioAuditingJobResp* resp);
  809. /*** 查询音频审核任务结果 ***/
  810. // https://cloud.tencent.com/document/product/436/54064
  811. CosResult DescribeAudioAuditingJob(const DescribeAudioAuditingJobReq& req,
  812. DescribeAudioAuditingJobResp* resp);
  813. /*** 提交文本审核任务 ***/
  814. // https://cloud.tencent.com/document/product/436/56289
  815. CosResult CreateTextAuditingJob(const CreateTextAuditingJobReq& req,
  816. CreateTextAuditingJobResp* resp);
  817. /*** 查询文本审核任务结果 ***/
  818. // https://cloud.tencent.com/document/product/436/56288
  819. CosResult DescribeTextAuditingJob(const DescribeTextAuditingJobReq& req,
  820. DescribeTextAuditingJobResp* resp);
  821. /*** 提交文档审核任务 ***/
  822. // https://cloud.tencent.com/document/product/436/59381
  823. CosResult CreateDocumentAuditingJob(const CreateDocumentAuditingJobReq& req,
  824. CreateDocumentAuditingJobResp* resp);
  825. /*** 查询文档审核任务结果 ***/
  826. // https://cloud.tencent.com/document/product/436/59382
  827. CosResult DescribeDocumentAuditingJob(const DescribeDocumentAuditingJobReq& req,
  828. DescribeDocumentAuditingJobResp* resp);
  829. /*** 提交网页审核任务 ***/
  830. // https://cloud.tencent.com/document/product/436/63958
  831. CosResult CreateWebPageAuditingJob(const CreateWebPageAuditingJobReq& req,
  832. CreateWebPageAuditingJobResp* resp);
  833. /*** 查询网页审核任务结果 ***/
  834. // https://cloud.tencent.com/document/product/436/63959
  835. CosResult DescribeWebPageAuditingJob(const DescribeWebPageAuditingJobReq& req,
  836. DescribeWebPageAuditingJobResp* resp);
  837. private:
  838. int CosInit();
  839. void CosUInit();
  840. private:
  841. // Be careful with the m_config order
  842. SharedConfig m_config;
  843. ObjectOp m_object_op; // 内部封装object相关的操作
  844. BucketOp m_bucket_op; // 内部封装bucket相关的操作
  845. ServiceOp m_service_op; // 内部封装service相关的操作
  846. static bool s_init;
  847. static bool s_poco_init;
  848. static int s_cos_obj_num;
  849. };
  850. } // namespace qcloud_cos
  851. #endif