public static void AsynListMultiUploads(COSXML.CosXml cosXml, string bucket) { ListMultiUploadsRequest request = new ListMultiUploadsRequest(bucket); //设置签名有效时长 request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600); //执行请求 cosXml.ListMultiUploads(request, delegate(CosResult cosResult) { ListMultiUploadsResult result = cosResult as ListMultiUploadsResult; Console.WriteLine(result.GetResultInfo()); }, delegate(CosClientException clientEx, CosServerException serverEx) { if (clientEx != null) { QLog.D("XIAO", clientEx.Message); Console.WriteLine("CosClientException: " + clientEx.Message); } if (serverEx != null) { QLog.D("XIAO", serverEx.Message); Console.WriteLine("CosServerException: " + serverEx.GetInfo()); } }); }
/// 列出所有未完成的分片上传任务 public void ListMultiUpload() { //.cssg-snippet-body-start:[list-multi-upload] try { string bucket = "examplebucket-1250000000"; //格式:BucketName-APPID ListMultiUploadsRequest request = new ListMultiUploadsRequest(bucket); //执行请求 ListMultiUploadsResult result = cosXml.ListMultiUploads(request); //请求成功 Console.WriteLine(result.GetResultInfo()); } catch (COSXML.CosException.CosClientException clientEx) { //请求失败 Console.WriteLine("CosClientException: " + clientEx); } catch (COSXML.CosException.CosServerException serverEx) { //请求失败 Console.WriteLine("CosServerException: " + serverEx.GetInfo()); } //.cssg-snippet-body-end }
public static void test(CosXml cosXml) { List <string> keys = new List <string>(); string bucket = "android-demo-ap-guangzhou"; GetBucketRequest getBucket = new GetBucketRequest(bucket); getBucket.Region = EnumUtils.GetValue(CosRegion.AP_Guangzhou); getBucket.SetSign(COSXML.Utils.TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600); GetBucketResult result = cosXml.GetBucket(getBucket); Console.WriteLine(result.GetResultInfo()); foreach (ListBucket.Contents content in result.listBucket.contentsList) { if (content != null) { keys.Add(content.key); } } if (keys.Count > 0) { COSXML.Model.Object.DeleteMultiObjectRequest deleteMults = new COSXML.Model.Object.DeleteMultiObjectRequest(bucket); deleteMults.SetSign(COSXML.Utils.TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600); deleteMults.Region = EnumUtils.GetValue(CosRegion.AP_Guangzhou); deleteMults.SetObjectKeys(keys); COSXML.Model.Object.DeleteMultiObjectResult deleteMultisResult = cosXml.DeleteMultiObjects(deleteMults); Console.WriteLine(deleteMultisResult.GetResultInfo()); } ListMultiUploadsRequest listMultis = new ListMultiUploadsRequest(bucket); listMultis.Region = EnumUtils.GetValue(CosRegion.AP_Guangzhou); listMultis.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600); ListMultiUploadsResult listMultisResult = cosXml.ListMultiUploads(listMultis); Console.WriteLine(listMultisResult.GetResultInfo()); if (listMultisResult.listMultipartUploads.uploads.Count > 0) { foreach (ListMultipartUploads.Upload upload in listMultisResult.listMultipartUploads.uploads) { if (upload == null) { continue; } string key = upload.key; string uploadId = upload.uploadID; COSXML.Model.Object.AbortMultiUploadRequest abort = new COSXML.Model.Object.AbortMultiUploadRequest(bucket, key, uploadId); abort.Region = EnumUtils.GetValue(CosRegion.AP_Guangzhou); abort.SetSign(COSXML.Utils.TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600); COSXML.Model.Object.AbortMultiUploadResult abortResult = cosXml.AbortMultiUpload(abort); } } }
public static void ListMultiUploads(COSXML.CosXml cosXml, string bucket) { try { ListMultiUploadsRequest request = new ListMultiUploadsRequest(bucket); //设置签名有效时长 request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600); //执行请求 ListMultiUploadsResult result = cosXml.ListMultiUploads(request); Console.WriteLine(result.GetResultInfo()); } catch (COSXML.CosException.CosClientException clientEx) { QLog.D("XIAO", clientEx.Message); Console.WriteLine("CosClientException: " + clientEx.Message); } catch (COSXML.CosException.CosServerException serverEx) { QLog.D("XIAO", serverEx.Message); Console.WriteLine("CosServerException: " + serverEx.GetInfo()); } }