CosXmlServer.cs 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4. using System.Text;
  5. using COSXML.Network;
  6. using COSXML.Model;
  7. using COSXML.Model.CI;
  8. using COSXML.Model.Service;
  9. using COSXML.Model.Object;
  10. using COSXML.Model.Bucket;
  11. using COSXML.Auth;
  12. using COSXML.Log;
  13. using COSXML.Utils;
  14. using COSXML.CosException;
  15. using COSXML.Common;
  16. using COSXML.Model.Tag;
  17. using COSXML.Callback;
  18. using System.Diagnostics.CodeAnalysis;
  19. #if !COMPATIBLE
  20. using System.Threading.Tasks;
  21. #endif
  22. namespace COSXML
  23. {
  24. /// <summary>
  25. /// CosXml 实现类
  26. /// </summary>
  27. public class CosXmlServer : CosXml
  28. {
  29. private CosXmlConfig config;
  30. private QCloudCredentialProvider credentialProvider;
  31. private HttpClient httpClient;
  32. /// <summary>
  33. /// 创建一个新实例
  34. /// </summary>
  35. /// <param name="config">服务配置</param>
  36. /// <param name="qcloudCredentailProvider">凭证提供者</param>
  37. public CosXmlServer(CosXmlConfig config, QCloudCredentialProvider qcloudCredentailProvider)
  38. {
  39. if (config == null)
  40. {
  41. throw new CosClientException((int) CosClientError.InvalidArgument, "Config is null.");
  42. }
  43. this.config = config;
  44. if (this.config.IsDebugLog)
  45. {
  46. QLog.AddLogAdapter(new LogImpl());
  47. }
  48. this.credentialProvider = qcloudCredentailProvider;
  49. httpClient = HttpClient.GetInstance();
  50. httpClient.Init(this.config.HttpConfig);
  51. }
  52. /// <summary>
  53. /// 获取配置
  54. /// </summary>
  55. /// <returns></returns>
  56. public CosXmlConfig GetConfig()
  57. {
  58. return config;
  59. }
  60. private void CheckAppidAndRegion(CosRequest request)
  61. {
  62. request.serviceConfig = config;
  63. if (request.IsHttps == null)
  64. {
  65. request.IsHttps = config.IsHttps;
  66. }
  67. if (request is GetServiceRequest)
  68. {
  69. return;
  70. }
  71. if (request.APPID == null)
  72. {
  73. request.APPID = config.Appid;
  74. }
  75. if (request is ObjectRequest)
  76. {
  77. if (((ObjectRequest)request).Region == null)
  78. {
  79. ((ObjectRequest)request).Region = config.Region;
  80. }
  81. return;
  82. }
  83. if (request is BucketRequest)
  84. {
  85. if (((BucketRequest)request).Region == null)
  86. {
  87. ((BucketRequest)request).Region = config.Region;
  88. }
  89. return;
  90. }
  91. }
  92. #if !COMPATIBLE
  93. public Task<T> ExecuteAsync<T>(CosRequest request) where T : CosResult
  94. {
  95. T result = Activator.CreateInstance<T>();
  96. CheckAppidAndRegion(request);
  97. var t = new TaskCompletionSource<T>();
  98. Schedue(request, result,
  99. delegate(CosResult cosResult)
  100. {
  101. t.TrySetResult(result as T);
  102. }
  103. , delegate(CosClientException clientException, CosServerException serverException)
  104. {
  105. if (clientException != null)
  106. {
  107. t.TrySetException(clientException);
  108. }
  109. else
  110. {
  111. t.TrySetException(serverException);
  112. }
  113. }
  114. );
  115. return t.Task;
  116. }
  117. #endif
  118. public T Execute<T>(CosRequest request) where T : CosResult
  119. {
  120. T result = Activator.CreateInstance<T>();
  121. return (T)Excute(request, result);
  122. }
  123. private T Execute<T>(CosRequest request, T result) where T : CosResult
  124. {
  125. return (T)Excute(request, result);
  126. }
  127. private CosResult Excute(CosRequest request, CosResult result)
  128. {
  129. CheckAppidAndRegion(request);
  130. httpClient.Excute(request, result, credentialProvider);
  131. return result;
  132. }
  133. private void Schedue(CosRequest request, CosResult result, COSXML.Callback.OnSuccessCallback<CosResult> successCallback, COSXML.Callback.OnFailedCallback failCallback)
  134. {
  135. CheckAppidAndRegion(request);
  136. httpClient.Schedue(request, result, successCallback, failCallback, credentialProvider);
  137. }
  138. public Model.Service.GetServiceResult GetService(Model.Service.GetServiceRequest request)
  139. {
  140. return (Model.Service.GetServiceResult)Excute(request, new Model.Service.GetServiceResult());
  141. }
  142. public void GetService(Model.Service.GetServiceRequest request, COSXML.Callback.OnSuccessCallback<CosResult> successCallback, COSXML.Callback.OnFailedCallback failCallback)
  143. {
  144. Schedue(request, new GetServiceResult(), successCallback, failCallback);
  145. }
  146. public PutBucketResult PutBucket(PutBucketRequest request)
  147. {
  148. return (Model.Bucket.PutBucketResult)Excute(request, new Model.Bucket.PutBucketResult());
  149. }
  150. public void PutBucket(PutBucketRequest request, COSXML.Callback.OnSuccessCallback<CosResult> successCallback, COSXML.Callback.OnFailedCallback failCallback)
  151. {
  152. Schedue(request, new PutBucketResult(), successCallback, failCallback);
  153. }
  154. public DeleteBucketResult DeleteBucket(DeleteBucketRequest request)
  155. {
  156. return (Model.Bucket.DeleteBucketResult)Excute(request, new Model.Bucket.DeleteBucketResult());
  157. }
  158. public void DeleteBucket(DeleteBucketRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  159. {
  160. Schedue(request, new DeleteBucketResult(), successCallback, failCallback);
  161. }
  162. public HeadBucketResult HeadBucket(HeadBucketRequest request)
  163. {
  164. return (Model.Bucket.HeadBucketResult)Excute(request, new Model.Bucket.HeadBucketResult());
  165. }
  166. public bool DoesBucketExist(DoesBucketExistRequest request)
  167. {
  168. try {
  169. CosResult result = Excute(request, new Model.Bucket.HeadBucketResult());
  170. if (result.httpCode == 200) {
  171. return true;
  172. }
  173. return false;
  174. }
  175. catch (CosServerException serverEx) {
  176. if (serverEx.statusCode == 404) {
  177. return false;
  178. } else {
  179. throw serverEx;
  180. }
  181. }
  182. catch (Exception e) {
  183. throw e;
  184. }
  185. }
  186. public void HeadBucket(HeadBucketRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  187. {
  188. Schedue(request, new HeadBucketResult(), successCallback, failCallback);
  189. }
  190. public GetBucketResult GetBucket(GetBucketRequest request)
  191. {
  192. return (Model.Bucket.GetBucketResult)Excute(request, new Model.Bucket.GetBucketResult());
  193. }
  194. public void GetBucket(GetBucketRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  195. {
  196. Schedue(request, new GetBucketResult(), successCallback, failCallback);
  197. }
  198. public PutBucketACLResult PutBucketACL(PutBucketACLRequest request)
  199. {
  200. return (Model.Bucket.PutBucketACLResult)Excute(request, new Model.Bucket.PutBucketACLResult());
  201. }
  202. public void PutBucketACL(PutBucketACLRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  203. {
  204. Schedue(request, new PutBucketACLResult(), successCallback, failCallback);
  205. }
  206. public GetBucketACLResult GetBucketACL(GetBucketACLRequest request)
  207. {
  208. return (Model.Bucket.GetBucketACLResult)Excute(request, new Model.Bucket.GetBucketACLResult());
  209. }
  210. public void GetBucketACL(GetBucketACLRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  211. {
  212. Schedue(request, new GetBucketACLResult(), successCallback, failCallback);
  213. }
  214. public PutBucketCORSResult PutBucketCORS(PutBucketCORSRequest request)
  215. {
  216. return (Model.Bucket.PutBucketCORSResult)Excute(request, new Model.Bucket.PutBucketCORSResult());
  217. }
  218. public void PutBucketCORS(PutBucketCORSRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  219. {
  220. Schedue(request, new PutBucketCORSResult(), successCallback, failCallback);
  221. }
  222. public GetBucketCORSResult GetBucketCORS(GetBucketCORSRequest request)
  223. {
  224. return (Model.Bucket.GetBucketCORSResult)Excute(request, new Model.Bucket.GetBucketCORSResult());
  225. }
  226. public void GetBucketCORS(GetBucketCORSRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  227. {
  228. Schedue(request, new GetBucketCORSResult(), successCallback, failCallback);
  229. }
  230. public DeleteBucketCORSResult DeleteBucketCORS(DeleteBucketCORSRequest request)
  231. {
  232. return (Model.Bucket.DeleteBucketCORSResult)Excute(request, new Model.Bucket.DeleteBucketCORSResult());
  233. }
  234. public void DeleteBucketCORS(DeleteBucketCORSRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  235. {
  236. Schedue(request, new DeleteBucketCORSResult(), successCallback, failCallback);
  237. }
  238. public PutBucketLifecycleResult PutBucketLifecycle(PutBucketLifecycleRequest request)
  239. {
  240. return (Model.Bucket.PutBucketLifecycleResult)Excute(request, new Model.Bucket.PutBucketLifecycleResult());
  241. }
  242. public void PutBucketLifecycle(PutBucketLifecycleRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  243. {
  244. Schedue(request, new PutBucketLifecycleResult(), successCallback, failCallback);
  245. }
  246. public GetBucketLifecycleResult GetBucketLifecycle(GetBucketLifecycleRequest request)
  247. {
  248. return (Model.Bucket.GetBucketLifecycleResult)Excute(request, new Model.Bucket.GetBucketLifecycleResult());
  249. }
  250. public void GetBucketLifecycle(GetBucketLifecycleRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  251. {
  252. Schedue(request, new GetBucketLifecycleResult(), successCallback, failCallback);
  253. }
  254. public DeleteBucketLifecycleResult DeleteBucketLifecycle(DeleteBucketLifecycleRequest request)
  255. {
  256. return (Model.Bucket.DeleteBucketLifecycleResult)Excute(request, new Model.Bucket.DeleteBucketLifecycleResult());
  257. }
  258. public void DeleteBucketLifecycle(DeleteBucketLifecycleRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  259. {
  260. Schedue(request, new DeleteBucketLifecycleResult(), successCallback, failCallback);
  261. }
  262. public PutBucketReplicationResult PutBucketReplication(PutBucketReplicationRequest request)
  263. {
  264. return (Model.Bucket.PutBucketReplicationResult)Excute(request, new Model.Bucket.PutBucketReplicationResult());
  265. }
  266. public void PutBucketReplication(PutBucketReplicationRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  267. {
  268. Schedue(request, new PutBucketReplicationResult(), successCallback, failCallback);
  269. }
  270. public GetBucketReplicationResult GetBucketReplication(GetBucketReplicationRequest request)
  271. {
  272. return (Model.Bucket.GetBucketReplicationResult)Excute(request, new Model.Bucket.GetBucketReplicationResult());
  273. }
  274. public void GetBucketReplication(GetBucketReplicationRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  275. {
  276. Schedue(request, new GetBucketReplicationResult(), successCallback, failCallback);
  277. }
  278. public DeleteBucketReplicationResult DeleteBucketReplication(DeleteBucketReplicationRequest request)
  279. {
  280. return (Model.Bucket.DeleteBucketReplicationResult)Excute(request, new Model.Bucket.DeleteBucketReplicationResult());
  281. }
  282. public void DeleteBucketReplication(DeleteBucketReplicationRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  283. {
  284. Schedue(request, new DeleteBucketReplicationResult(), successCallback, failCallback);
  285. }
  286. public PutBucketVersioningResult PutBucketVersioning(PutBucketVersioningRequest request)
  287. {
  288. return (Model.Bucket.PutBucketVersioningResult)Excute(request, new Model.Bucket.PutBucketVersioningResult());
  289. }
  290. public void PutBucketVersioning(PutBucketVersioningRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  291. {
  292. Schedue(request, new PutBucketVersioningResult(), successCallback, failCallback);
  293. }
  294. public GetBucketVersioningResult GetBucketVersioning(GetBucketVersioningRequest request)
  295. {
  296. return (Model.Bucket.GetBucketVersioningResult)Excute(request, new Model.Bucket.GetBucketVersioningResult());
  297. }
  298. public void GetBucketVersioning(GetBucketVersioningRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  299. {
  300. Schedue(request, new GetBucketVersioningResult(), successCallback, failCallback);
  301. }
  302. public ListBucketVersionsResult ListBucketVersions(ListBucketVersionsRequest request)
  303. {
  304. return (Model.Bucket.ListBucketVersionsResult)Excute(request, new Model.Bucket.ListBucketVersionsResult());
  305. }
  306. public void ListBucketVersions(ListBucketVersionsRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  307. {
  308. Schedue(request, new ListBucketVersionsResult(), successCallback, failCallback);
  309. }
  310. public ListMultiUploadsResult ListMultiUploads(ListMultiUploadsRequest request)
  311. {
  312. return (Model.Bucket.ListMultiUploadsResult)Excute(request, new Model.Bucket.ListMultiUploadsResult());
  313. }
  314. public PutBucketRefererResult PutBucketReferer(PutBucketRefererRequest request)
  315. {
  316. return (Model.Bucket.PutBucketRefererResult)Excute(request, new Model.Bucket.PutBucketRefererResult());
  317. }
  318. public void PutBucketReferer(PutBucketRefererRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  319. {
  320. Schedue(request, new PutBucketRefererResult(), successCallback, failCallback);
  321. }
  322. public GetBucketRefererResult GetBucketReferer(GetBucketRefererRequest request)
  323. {
  324. return (Model.Bucket.GetBucketRefererResult)Excute(request, new Model.Bucket.GetBucketRefererResult());
  325. }
  326. public void GetBucketReferer(GetBucketRefererRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  327. {
  328. Schedue(request, new GetBucketRefererResult(), successCallback, failCallback);
  329. }
  330. public void ListMultiUploads(ListMultiUploadsRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  331. {
  332. Schedue(request, new ListMultiUploadsResult(), successCallback, failCallback);
  333. }
  334. public DeleteBucketPolicyResult DeleteBucketPolicy(DeleteBucketPolicyRequest request)
  335. {
  336. return (Model.Bucket.DeleteBucketPolicyResult)Excute(request, new Model.Bucket.DeleteBucketPolicyResult());
  337. }
  338. public void DeleteBucketPolicy(DeleteBucketPolicyRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  339. {
  340. Schedue(request, new DeleteBucketPolicyResult(), successCallback, failCallback);
  341. }
  342. public PutObjectResult PutObject(PutObjectRequest request)
  343. {
  344. return (Model.Object.PutObjectResult)Excute(request, new Model.Object.PutObjectResult());
  345. }
  346. public void PutObject(PutObjectRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  347. {
  348. Schedue(request, new PutObjectResult(), successCallback, failCallback);
  349. }
  350. public void AppendObject(AppendObjectRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  351. {
  352. Schedue(request, new AppendObjectResult(), successCallback, failCallback);
  353. }
  354. public AppendObjectResult AppendObject(AppendObjectRequest request)
  355. {
  356. return (Model.Object.AppendObjectResult)Excute(request, new Model.Object.AppendObjectResult());
  357. }
  358. public HeadObjectResult HeadObject(HeadObjectRequest request)
  359. {
  360. return (Model.Object.HeadObjectResult)Excute(request, new Model.Object.HeadObjectResult());
  361. }
  362. public void HeadObject(HeadObjectRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  363. {
  364. Schedue(request, new HeadObjectResult(), successCallback, failCallback);
  365. }
  366. public bool DoesObjectExist(DoesObjectExistRequest request)
  367. {
  368. try {
  369. CosResult result = Excute(request, new Model.Object.HeadObjectResult());
  370. if (result.httpCode == 200) {
  371. return true;
  372. }
  373. return false;
  374. }
  375. catch (CosServerException serverEx) {
  376. if (serverEx.statusCode == 404) {
  377. return false;
  378. }
  379. else {
  380. throw serverEx;
  381. }
  382. }
  383. catch (Exception e) {
  384. throw e;
  385. }
  386. }
  387. public GetObjectResult GetObject(GetObjectRequest request)
  388. {
  389. return (Model.Object.GetObjectResult)Excute(request, new Model.Object.GetObjectResult());
  390. }
  391. public void GetObject(GetObjectRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  392. {
  393. Schedue(request, new GetObjectResult(), successCallback, failCallback);
  394. }
  395. public PutObjectACLResult PutObjectACL(PutObjectACLRequest request)
  396. {
  397. return (Model.Object.PutObjectACLResult)Excute(request, new Model.Object.PutObjectACLResult());
  398. }
  399. public void PutObjectACL(PutObjectACLRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  400. {
  401. Schedue(request, new PutObjectACLResult(), successCallback, failCallback);
  402. }
  403. public GetObjectACLResult GetObjectACL(GetObjectACLRequest request)
  404. {
  405. return (Model.Object.GetObjectACLResult)Excute(request, new Model.Object.GetObjectACLResult());
  406. }
  407. public void GetObjectACL(GetObjectACLRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  408. {
  409. Schedue(request, new GetObjectACLResult(), successCallback, failCallback);
  410. }
  411. public PutObjectTaggingResult PutObjectTagging(PutObjectTaggingRequest request)
  412. {
  413. return (Model.Object.PutObjectTaggingResult)Excute(request, new Model.Object.PutObjectTaggingResult());
  414. }
  415. public void PutObjectTagging(PutObjectTaggingRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  416. {
  417. Schedue(request, new PutObjectTaggingResult(), successCallback, failCallback);
  418. }
  419. public GetObjectTaggingResult GetObjectTagging(GetObjectTaggingRequest request)
  420. {
  421. return (Model.Object.GetObjectTaggingResult)Excute(request, new Model.Object.GetObjectTaggingResult());
  422. }
  423. public void GetObjectTagging(GetObjectTaggingRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  424. {
  425. Schedue(request, new GetObjectTaggingResult(), successCallback, failCallback);
  426. }
  427. public DeleteObjectTaggingResult DeleteObjectTagging(DeleteObjectTaggingRequest request)
  428. {
  429. return (Model.Object.DeleteObjectTaggingResult)Excute(request, new Model.Object.DeleteObjectTaggingResult());
  430. }
  431. public void DeleteObjectTagging(DeleteObjectTaggingRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  432. {
  433. Schedue(request, new DeleteObjectTaggingResult(), successCallback, failCallback);
  434. }
  435. public DeleteObjectResult DeleteObject(DeleteObjectRequest request)
  436. {
  437. return (Model.Object.DeleteObjectResult)Excute(request, new Model.Object.DeleteObjectResult());
  438. }
  439. public void DeleteObject(DeleteObjectRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  440. {
  441. Schedue(request, new DeleteObjectResult(), successCallback, failCallback);
  442. }
  443. public DeleteMultiObjectResult DeleteMultiObjects(DeleteMultiObjectRequest request)
  444. {
  445. return (Model.Object.DeleteMultiObjectResult)Excute(request, new Model.Object.DeleteMultiObjectResult());
  446. }
  447. public void DeleteMultiObjects(DeleteMultiObjectRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  448. {
  449. Schedue(request, new DeleteMultiObjectResult(), successCallback, failCallback);
  450. }
  451. public InitMultipartUploadResult InitMultipartUpload(InitMultipartUploadRequest request)
  452. {
  453. return (Model.Object.InitMultipartUploadResult)Excute(request, new Model.Object.InitMultipartUploadResult());
  454. }
  455. public void InitMultipartUpload(InitMultipartUploadRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  456. {
  457. Schedue(request, new InitMultipartUploadResult(), successCallback, failCallback);
  458. }
  459. public ListPartsResult ListParts(ListPartsRequest request)
  460. {
  461. return (Model.Object.ListPartsResult)Excute(request, new Model.Object.ListPartsResult());
  462. }
  463. public void ListParts(ListPartsRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  464. {
  465. Schedue(request, new ListPartsResult(), successCallback, failCallback);
  466. }
  467. public UploadPartResult UploadPart(UploadPartRequest request)
  468. {
  469. return (Model.Object.UploadPartResult)Excute(request, new Model.Object.UploadPartResult());
  470. }
  471. public void UploadPart(UploadPartRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  472. {
  473. Schedue(request, new UploadPartResult(), successCallback, failCallback);
  474. }
  475. public CompleteMultipartUploadResult CompleteMultiUpload(CompleteMultipartUploadRequest request)
  476. {
  477. return (Model.Object.CompleteMultipartUploadResult)Excute(request, new Model.Object.CompleteMultipartUploadResult());
  478. }
  479. public void CompleteMultiUpload(CompleteMultipartUploadRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  480. {
  481. Schedue(request, new CompleteMultipartUploadResult(), successCallback, failCallback);
  482. }
  483. public AbortMultipartUploadResult AbortMultiUpload(AbortMultipartUploadRequest request)
  484. {
  485. return (Model.Object.AbortMultipartUploadResult)Excute(request, new Model.Object.AbortMultipartUploadResult());
  486. }
  487. public void AbortMultiUpload(AbortMultipartUploadRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  488. {
  489. Schedue(request, new AbortMultipartUploadResult(), successCallback, failCallback);
  490. }
  491. public CopyObjectResult CopyObject(CopyObjectRequest request)
  492. {
  493. return (Model.Object.CopyObjectResult)Excute(request, new Model.Object.CopyObjectResult());
  494. }
  495. public void CopyObject(CopyObjectRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  496. {
  497. Schedue(request, new CopyObjectResult(), successCallback, failCallback);
  498. }
  499. public UploadPartCopyResult PartCopy(UploadPartCopyRequest request)
  500. {
  501. return (Model.Object.UploadPartCopyResult)Excute(request, new Model.Object.UploadPartCopyResult());
  502. }
  503. public void PartCopy(UploadPartCopyRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  504. {
  505. Schedue(request, new UploadPartCopyResult(), successCallback, failCallback);
  506. }
  507. public OptionObjectResult OptionObject(OptionObjectRequest request)
  508. {
  509. return (Model.Object.OptionObjectResult)Excute(request, new Model.Object.OptionObjectResult());
  510. }
  511. public void OptionObject(OptionObjectRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  512. {
  513. Schedue(request, new OptionObjectResult(), successCallback, failCallback);
  514. }
  515. public PostObjectResult PostObject(PostObjectRequest request)
  516. {
  517. return (Model.Object.PostObjectResult)Excute(request, new Model.Object.PostObjectResult());
  518. }
  519. public void PostObject(PostObjectRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  520. {
  521. Schedue(request, new PostObjectResult(), successCallback, failCallback);
  522. }
  523. public RestoreObjectResult RestoreObject(RestoreObjectRequest request)
  524. {
  525. return (Model.Object.RestoreObjectResult)Excute(request, new Model.Object.RestoreObjectResult());
  526. }
  527. public void RestoreObject(RestoreObjectRequest request, Callback.OnSuccessCallback<CosResult> successCallback, Callback.OnFailedCallback failCallback)
  528. {
  529. Schedue(request, new RestoreObjectResult(), successCallback, failCallback);
  530. }
  531. public string GenerateSign(string method, string key, Dictionary<string, string> queryParameters,
  532. Dictionary<string, string> headers, long signDurationSecond, long keyDurationSecond)
  533. {
  534. try
  535. {
  536. string signTime = null;
  537. long currentTimeSecond = TimeUtils_QCloud.GetCurrentTime(TimeUnit.Seconds);
  538. if (signDurationSecond > 0)
  539. {
  540. signTime = String.Format("{0};{1}", currentTimeSecond, currentTimeSecond + signDurationSecond);
  541. }
  542. string keyTime = null;
  543. if (keyDurationSecond > 0)
  544. {
  545. signTime = String.Format("{0};{1}", currentTimeSecond, currentTimeSecond + keyDurationSecond);
  546. }
  547. Dictionary<string, string> encodeQuery = null;
  548. if (queryParameters != null)
  549. {
  550. encodeQuery = new Dictionary<string, string>(queryParameters.Count);
  551. foreach (KeyValuePair<string, string> keyValuePair in queryParameters)
  552. {
  553. if (keyValuePair.Key == null || keyValuePair.Key == "")
  554. {
  555. continue;
  556. }
  557. else if (keyValuePair.Value == null)
  558. {
  559. encodeQuery[URLEncodeUtils.Encode(keyValuePair.Key).ToLower()] = URLEncodeUtils.Encode("");
  560. }
  561. else
  562. {
  563. encodeQuery[URLEncodeUtils.Encode(keyValuePair.Key).ToLower()] = URLEncodeUtils.Encode(keyValuePair.Value);
  564. }
  565. }
  566. }
  567. return CosXmlSigner.GenerateSign(method, key, encodeQuery, headers, signTime, keyTime, credentialProvider.GetQCloudCredentialsCompat(null));
  568. }
  569. catch (CosClientException)
  570. {
  571. throw;
  572. }
  573. catch (Exception ex)
  574. {
  575. throw new CosClientException((int)CosClientError.InvalidArgument, ex.Message, ex);
  576. }
  577. }
  578. public string GenerateSignURL(PreSignatureStruct preSignatureStruct)
  579. {
  580. try
  581. {
  582. if (preSignatureStruct.httpMethod == null)
  583. {
  584. throw new CosClientException((int)CosClientError.InvalidArgument, "httpMethod = null");
  585. }
  586. if (preSignatureStruct.key == null)
  587. {
  588. throw new CosClientException((int)CosClientError.InvalidArgument, "key = null");
  589. }
  590. StringBuilder urlBuilder = new StringBuilder();
  591. if (preSignatureStruct.isHttps)
  592. {
  593. urlBuilder.Append("https://");
  594. }
  595. else
  596. {
  597. urlBuilder.Append("http://");
  598. }
  599. if (preSignatureStruct.host == null)
  600. {
  601. StringBuilder host = new StringBuilder();
  602. if (preSignatureStruct.bucket == null)
  603. {
  604. throw new CosClientException((int)CosClientError.InvalidArgument, "bucket = null");
  605. }
  606. if (preSignatureStruct.bucket.EndsWith("-" + preSignatureStruct.appid))
  607. {
  608. host.Append(preSignatureStruct.bucket);
  609. }
  610. else
  611. {
  612. host.Append(preSignatureStruct.bucket).Append("-")
  613. .Append(preSignatureStruct.appid);
  614. }
  615. host.Append(".cos.")
  616. .Append(preSignatureStruct.region)
  617. .Append(".myqcloud.com");
  618. urlBuilder.Append(host.ToString());
  619. // host 入签
  620. if (preSignatureStruct.signHost)
  621. {
  622. if (preSignatureStruct.headers == null)
  623. {
  624. preSignatureStruct.headers = new Dictionary<string, string>();
  625. }
  626. if (!preSignatureStruct.headers.ContainsKey("host"))
  627. preSignatureStruct.headers.Add("host", host.ToString());
  628. }
  629. }
  630. else
  631. {
  632. urlBuilder.Append(preSignatureStruct.host);
  633. // host 入签
  634. if (preSignatureStruct.signHost) {
  635. if (preSignatureStruct.headers == null)
  636. {
  637. preSignatureStruct.headers = new Dictionary<string, string>();
  638. }
  639. preSignatureStruct.headers.Add("host", preSignatureStruct.host);
  640. }
  641. }
  642. if (!preSignatureStruct.key.StartsWith("/"))
  643. {
  644. preSignatureStruct.key = "/" + preSignatureStruct.key;
  645. }
  646. urlBuilder.Append(preSignatureStruct.key.Replace("+", "%2B"));
  647. string sign = GenerateSign(preSignatureStruct.httpMethod, preSignatureStruct.key,
  648. preSignatureStruct.queryParameters, preSignatureStruct.headers,
  649. preSignatureStruct.signDurationSecond, preSignatureStruct.keyDurationSecond);
  650. StringBuilder queryBuilder = new StringBuilder();
  651. if (preSignatureStruct.queryParameters != null && preSignatureStruct.queryParameters.Count > 0)
  652. {
  653. foreach (KeyValuePair<string, string> keyValuePair in preSignatureStruct.queryParameters)
  654. {
  655. if (keyValuePair.Key == null || keyValuePair.Key == "")
  656. continue;
  657. queryBuilder.Append(URLEncodeUtils.Encode(keyValuePair.Key)).Append('=').Append(URLEncodeUtils.Encode(keyValuePair.Value));
  658. queryBuilder.Append('&');
  659. }
  660. }
  661. // 针对需要二次 Encode 的 request Param 特殊处理
  662. Regex rgx = new Regex("q-url-param-list=.*&q-signature");
  663. string paramlist = rgx.Match(sign).ToString().Split('=')[1].ToString().Split('&')[0].ToString();
  664. paramlist = paramlist.Trim('&');
  665. paramlist = URLEncodeUtils.Encode(paramlist).ToLower();
  666. string encodedStr = "q-url-param-list=" + paramlist + "&q-signature";
  667. sign = rgx.Replace(sign, encodedStr);
  668. queryBuilder.Append(sign);
  669. urlBuilder.Append("?").Append(queryBuilder.ToString());
  670. return urlBuilder.ToString();
  671. }
  672. catch (CosClientException)
  673. {
  674. throw;
  675. }
  676. catch (Exception ex)
  677. {
  678. throw new CosClientException((int)CosClientError.InvalidArgument, ex.Message, ex);
  679. }
  680. }
  681. public void Cancel(CosRequest cosRequest)
  682. {
  683. if (cosRequest != null)
  684. {
  685. cosRequest.Cancel();
  686. }
  687. }
  688. public GetObjectBytesResult GetObject(GetObjectBytesRequest request)
  689. {
  690. return (Model.Object.GetObjectBytesResult)Excute(request, new Model.Object.GetObjectBytesResult());
  691. }
  692. public void GetObject(GetObjectBytesRequest request, OnSuccessCallback<CosResult> successCallback, OnFailedCallback failCallback)
  693. {
  694. Schedue(request, new GetObjectBytesResult(), successCallback, failCallback);
  695. }
  696. public string GetObjectUrl(string bucket, string key)
  697. {
  698. string http_prefix = config.IsHttps ? "https://" : "http://";
  699. StringBuilder domainSuffix = new StringBuilder();
  700. // 优先自定义域名
  701. if (this.config.host != null) {
  702. domainSuffix.Append(this.config.host).Append("/").Append(key);
  703. return http_prefix + domainSuffix.ToString();
  704. }
  705. // endpoint
  706. else if (this.config.endpointSuffix != null) {
  707. domainSuffix.Append(".").Append(this.config.endpointSuffix).Append("/").Append(key);
  708. }
  709. // 默认域名
  710. else {
  711. domainSuffix.Append(".cos.");
  712. domainSuffix.Append(this.config.Region).Append(".myqcloud.com/").Append(key);
  713. }
  714. return http_prefix + bucket + domainSuffix.ToString();
  715. }
  716. public PutBucketWebsiteResult PutBucketWebsite(PutBucketWebsiteRequest request)
  717. {
  718. return (Model.Bucket.PutBucketWebsiteResult)Excute(request, new Model.Bucket.PutBucketWebsiteResult());
  719. }
  720. public void PutBucketWebsiteAsync(PutBucketWebsiteRequest request, OnSuccessCallback<CosResult> successCallback, OnFailedCallback failCallback)
  721. {
  722. Schedue(request, new Model.Bucket.PutBucketWebsiteResult(), successCallback, failCallback);
  723. }
  724. public GetBucketWebsiteResult GetBucketWebsite(GetBucketWebsiteRequest request)
  725. {
  726. return (Model.Bucket.GetBucketWebsiteResult)Excute(request, new Model.Bucket.GetBucketWebsiteResult());
  727. }
  728. public void GetBucketWebsiteAsync(GetBucketWebsiteRequest request, OnSuccessCallback<CosResult> successCallback, OnFailedCallback failCallback)
  729. {
  730. Schedue(request, new Model.Bucket.GetBucketWebsiteResult(), successCallback, failCallback);
  731. }
  732. public DeleteBucketWebsiteResult DeleteBucketWebsite(DeleteBucketWebsiteRequest request)
  733. {
  734. return (Model.Bucket.DeleteBucketWebsiteResult)Excute(request, new Model.Bucket.DeleteBucketWebsiteResult());
  735. }
  736. public void DeleteBucketWebsiteAsync(DeleteBucketWebsiteRequest request, OnSuccessCallback<CosResult> successCallback, OnFailedCallback failCallback)
  737. {
  738. Schedue(request, new Model.Bucket.DeleteBucketWebsiteResult(), successCallback, failCallback);
  739. }
  740. public PutBucketLoggingResult PutBucketLogging(PutBucketLoggingRequest request)
  741. {
  742. return (Model.Bucket.PutBucketLoggingResult)Excute(request, new Model.Bucket.PutBucketLoggingResult());
  743. }
  744. public void PutBucketLoggingAsync(PutBucketLoggingRequest request, OnSuccessCallback<CosResult> successCallback, OnFailedCallback failCallback)
  745. {
  746. Schedue(request, new Model.Bucket.PutBucketLoggingResult(), successCallback, failCallback);
  747. }
  748. public GetBucketLoggingResult GetBucketLogging(GetBucketLoggingRequest request)
  749. {
  750. return (Model.Bucket.GetBucketLoggingResult)Excute(request, new Model.Bucket.GetBucketLoggingResult());
  751. }
  752. public void GetBucketLoggingAsync(GetBucketLoggingRequest request, OnSuccessCallback<CosResult> successCallback, OnFailedCallback failCallback)
  753. {
  754. Schedue(request, new Model.Bucket.GetBucketLoggingResult(), successCallback, failCallback);
  755. }
  756. public PutBucketInventoryResult PutBucketInventory(PutBucketInventoryRequest request)
  757. {
  758. return (Model.Bucket.PutBucketInventoryResult)Excute(request, new Model.Bucket.PutBucketInventoryResult());
  759. }
  760. public void PutBucketInventoryAsync(PutBucketInventoryRequest request, OnSuccessCallback<CosResult> successCallback, OnFailedCallback failCallback)
  761. {
  762. Schedue(request, new Model.Bucket.PutBucketInventoryResult(), successCallback, failCallback);
  763. }
  764. public GetBucketInventoryResult GetBucketInventory(GetBucketInventoryRequest request)
  765. {
  766. return (Model.Bucket.GetBucketInventoryResult)Excute(request, new Model.Bucket.GetBucketInventoryResult());
  767. }
  768. public void GetBucketInventoryAsync(GetBucketInventoryRequest request, OnSuccessCallback<CosResult> successCallback, OnFailedCallback failCallback)
  769. {
  770. Schedue(request, new Model.Bucket.GetBucketInventoryResult(), successCallback, failCallback);
  771. }
  772. public DeleteBucketInventoryResult DeleteBucketInventory(DeleteBucketInventoryRequest request)
  773. {
  774. return (Model.Bucket.DeleteBucketInventoryResult)Excute(request, new Model.Bucket.DeleteBucketInventoryResult());
  775. }
  776. public void DeleteInventoryAsync(DeleteBucketInventoryRequest request, OnSuccessCallback<CosResult> successCallback, OnFailedCallback failCallback)
  777. {
  778. Schedue(request, new Model.Bucket.DeleteBucketInventoryResult(), successCallback, failCallback);
  779. }
  780. public ListBucketInventoryResult ListBucketInventory(ListBucketInventoryRequest request)
  781. {
  782. return (Model.Bucket.ListBucketInventoryResult)Excute(request, new Model.Bucket.ListBucketInventoryResult());
  783. }
  784. public void ListBucketInventoryAsync(ListBucketInventoryRequest request, OnSuccessCallback<CosResult> successCallback, OnFailedCallback failCallback)
  785. {
  786. Schedue(request, new Model.Bucket.ListBucketInventoryResult(), successCallback, failCallback);
  787. }
  788. public PutBucketTaggingResult PutBucketTagging(PutBucketTaggingRequest request)
  789. {
  790. return (Model.Bucket.PutBucketTaggingResult)Excute(request, new Model.Bucket.PutBucketTaggingResult());
  791. }
  792. public void PutBucketTaggingAsync(PutBucketTaggingRequest request, COSXML.Callback.OnSuccessCallback<CosResult> successCallback, COSXML.Callback.OnFailedCallback failCallback)
  793. {
  794. Schedue(request, new Model.Bucket.PutBucketTaggingResult(), successCallback, failCallback);
  795. }
  796. public GetBucketTaggingResult GetBucketTagging(GetBucketTaggingRequest request)
  797. {
  798. return (Model.Bucket.GetBucketTaggingResult)Excute(request, new Model.Bucket.GetBucketTaggingResult());
  799. }
  800. public void GetBucketTaggingAsync(GetBucketTaggingRequest request, COSXML.Callback.OnSuccessCallback<CosResult> successCallback, COSXML.Callback.OnFailedCallback failCallback)
  801. {
  802. Schedue(request, new Model.Bucket.GetBucketTaggingResult(), successCallback, failCallback);
  803. }
  804. public DeleteBucketTaggingResult DeleteBucketTagging(DeleteBucketTaggingRequest request)
  805. {
  806. return (Model.Bucket.DeleteBucketTaggingResult)Excute(request, new Model.Bucket.DeleteBucketTaggingResult());
  807. }
  808. public void DeleteBucketTaggingAsync(DeleteBucketTaggingRequest request, COSXML.Callback.OnSuccessCallback<CosResult> successCallback, COSXML.Callback.OnFailedCallback failCallback)
  809. {
  810. Schedue(request, new Model.Bucket.DeleteBucketTaggingResult(), successCallback, failCallback);
  811. }
  812. public PutBucketDomainResult PutBucketDomain(PutBucketDomainRequest request)
  813. {
  814. return (Model.Bucket.PutBucketDomainResult)Excute(request, new Model.Bucket.PutBucketDomainResult());
  815. }
  816. public void PutBucketDomainAsync(PutBucketDomainRequest request, OnSuccessCallback<CosResult> successCallback, OnFailedCallback failCallback)
  817. {
  818. Schedue(request, new Model.Bucket.PutBucketDomainResult(), successCallback, failCallback);
  819. }
  820. public GetBucketDomainResult GetBucketDomain(GetBucketDomainRequest request)
  821. {
  822. return (Model.Bucket.GetBucketDomainResult)Excute(request, new Model.Bucket.GetBucketDomainResult());
  823. }
  824. public void GetBucketDomainAsync(GetBucketDomainRequest request, OnSuccessCallback<CosResult> successCallback, OnFailedCallback failCallback)
  825. {
  826. Schedue(request, new Model.Bucket.GetBucketDomainResult(), successCallback, failCallback);
  827. }
  828. SelectObjectResult CosXml.SelectObject(SelectObjectRequest request)
  829. {
  830. return (Model.Object.SelectObjectResult)Excute(request, new Model.Object.SelectObjectResult());
  831. }
  832. void CosXml.SelectObjectAsync(SelectObjectRequest request, OnSuccessCallback<CosResult> successCallback, OnFailedCallback failCallback)
  833. {
  834. Schedue(request, new Model.Object.SelectObjectResult(), successCallback, failCallback);
  835. }
  836. public GetBucketIntelligentTieringResult GetBucketIntelligentTieringConfiguration(GetBucketIntelligentTieringRequest request)
  837. {
  838. try
  839. {
  840. return Execute(request, new GetBucketIntelligentTieringResult());
  841. }
  842. catch (CosServerException e)
  843. {
  844. if (e.statusCode == 404)
  845. {
  846. return new GetBucketIntelligentTieringResult();
  847. }
  848. throw e;
  849. }
  850. }
  851. public CosResult PutBucketIntelligentTiering(PutBucketIntelligentTieringRequest request)
  852. {
  853. return Execute(request, new CosResult());
  854. }
  855. public SensitiveContentRecognitionResult SensitiveContentRecognition(SensitiveContentRecognitionRequest request)
  856. {
  857. return Execute(request, new SensitiveContentRecognitionResult());
  858. }
  859. /// <summary>
  860. /// 图片处理
  861. /// </summary>
  862. /// <param name="request"></param>
  863. /// <returns></returns>
  864. public ImageProcessResult ImageProcess(ImageProcessRequest request)
  865. {
  866. return Execute(request, new ImageProcessResult());
  867. }
  868. /// <summary>
  869. /// 下载时进行二维码识别
  870. /// </summary>
  871. /// <param name="request"></param>
  872. /// <returns></returns>
  873. public QRCodeRecognitionResult QRCodeRecognition(QRCodeRecognitionRequest request)
  874. {
  875. return Execute(request, new QRCodeRecognitionResult());
  876. }
  877. /// <summary>
  878. /// 获取媒体文件某个时间的截图
  879. /// </summary>
  880. /// <param name="request"></param>
  881. /// <returns></returns>
  882. public GetSnapshotResult GetSnapshot(GetSnapshotRequest request)
  883. {
  884. return Execute(request, new GetSnapshotResult());
  885. }
  886. /// <summary>
  887. /// 获取媒体文件的信息
  888. /// </summary>
  889. /// <param name="request"></param>
  890. /// <returns></returns>
  891. public GetMediaInfoResult GetMediaInfo(GetMediaInfoRequest request)
  892. {
  893. return Execute(request, new GetMediaInfoResult());
  894. }
  895. /// <summary>
  896. /// 提交视频审核任务
  897. /// </summary>
  898. /// <param name="request"></param>
  899. /// <returns></returns>
  900. public SubmitCensorJobResult SubmitVideoCensorJob(SubmitVideoCensorJobRequest request)
  901. {
  902. request.Region = this.GetConfig().Region;
  903. return Execute(request, new SubmitCensorJobResult());
  904. }
  905. /// <summary>
  906. /// 获取视频审核任务结果
  907. /// </summary>
  908. /// <param name="request"></param>
  909. /// <returns></returns>
  910. public GetVideoCensorJobResult GetVideoCensorJob(GetVideoCensorJobRequest request)
  911. {
  912. request.Region = this.GetConfig().Region;
  913. return Execute(request, new GetVideoCensorJobResult());
  914. }
  915. /// <summary>
  916. /// 提交音频审核任务
  917. /// </summary>
  918. /// <param name="request"></param>
  919. /// <returns></returns>
  920. public SubmitCensorJobResult SubmitAudioCensorJob(SubmitAudioCensorJobRequest request)
  921. {
  922. request.Region = this.GetConfig().Region;
  923. return Execute(request, new SubmitCensorJobResult());
  924. }
  925. /// <summary>
  926. /// 获取音频审核任务结果
  927. /// </summary>
  928. /// <param name="request"></param>
  929. /// <returns></returns>
  930. public GetAudioCensorJobResult GetAudioCensorJob(GetAudioCensorJobRequest request)
  931. {
  932. request.Region = this.GetConfig().Region;
  933. return Execute(request, new GetAudioCensorJobResult());
  934. }
  935. /// <summary>
  936. /// 提交文本审核任务
  937. /// </summary>
  938. /// <param name="request"></param>
  939. /// <returns></returns>
  940. public SubmitCensorJobResult SubmitTextCensorJob(SubmitTextCensorJobRequest request)
  941. {
  942. request.Region = this.GetConfig().Region;
  943. return Execute(request, new SubmitCensorJobResult());
  944. }
  945. /// <summary>
  946. /// 提交文本审核任务, 支持同步返回
  947. /// </summary>
  948. /// <param name="request"></param>
  949. /// <returns></returns>
  950. public SubmitTextCensorJobsResult SubmitTextCensorJobSync(SubmitTextCensorJobRequest request)
  951. {
  952. request.Region = this.GetConfig().Region;
  953. return Execute(request, new SubmitTextCensorJobsResult());
  954. }
  955. /// <summary>
  956. /// 获取文本审核任务结果
  957. /// </summary>
  958. /// <param name="request"></param>
  959. /// <returns></returns>
  960. public GetTextCensorJobResult GetTextCensorJob(GetTextCensorJobRequest request)
  961. {
  962. request.Region = this.GetConfig().Region;
  963. return Execute(request, new GetTextCensorJobResult());
  964. }
  965. /// <summary>
  966. /// 提交文档审核任务
  967. /// </summary>
  968. /// <param name="request"></param>
  969. /// <returns></returns>
  970. public SubmitCensorJobResult SubmitDocumentCensorJob(SubmitDocumentCensorJobRequest request)
  971. {
  972. request.Region = this.GetConfig().Region;
  973. return Execute(request, new SubmitCensorJobResult());
  974. }
  975. /// <summary>
  976. /// 获取文档审核任务结果
  977. /// </summary>
  978. /// <param name="request"></param>
  979. /// <returns></returns>
  980. public GetDocumentCensorJobResult GetDocumentCensorJob(GetDocumentCensorJobRequest request)
  981. {
  982. request.Region = this.GetConfig().Region;
  983. return Execute(request, new GetDocumentCensorJobResult());
  984. }
  985. /// <summary>
  986. /// 获取媒体bucket列表
  987. /// </summary>
  988. /// <param name="request"></param>
  989. /// <returns></returns>
  990. public DescribeMediaBucketsResult DescribeMediaBuckets(DescribeMediaBucketsRequest request)
  991. {
  992. request.Region = this.GetConfig().Region;
  993. return Execute(request, new DescribeMediaBucketsResult());
  994. }
  995. }
  996. }