public static void AsynAbortMultiUpload(COSXML.CosXml cosXml, string bucket, string key, string uploadId) { AbortMultipartUploadRequest request = new AbortMultipartUploadRequest(bucket, key, uploadId); //设置签名有效时长 request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600); //执行请求 cosXml.AbortMultiUpload(request, delegate(CosResult result) { AbortMultipartUploadResult getObjectResult = result as AbortMultipartUploadResult; Console.WriteLine(getObjectResult.GetResultInfo()); }, delegate(CosClientException clientEx, CosServerException serverEx) { if (clientEx != null) { QLog.D("XIAO", clientEx.Message); Console.WriteLine("CosClientException: " + clientEx.StackTrace); } if (serverEx != null) { QLog.D("XIAO", serverEx.Message); Console.WriteLine("CosServerException: " + serverEx.GetInfo()); } }); }
public void AbortMultiUpload(COSXML.CosXml cosXml, string bucket, string key, string srcPath) { try { InitMultipartUploadRequest initMultipartUploadRequest = new InitMultipartUploadRequest(bucket, key); //设置签名有效时长 initMultipartUploadRequest.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600); //执行请求 InitMultipartUploadResult initMultipartUploadResult = cosXml.InitMultipartUpload(initMultipartUploadRequest); Console.WriteLine(initMultipartUploadResult.GetResultInfo()); string uploadId = initMultipartUploadResult.initMultipartUpload.uploadId; AbortMultipartUploadRequest request = new AbortMultipartUploadRequest(bucket, key, uploadId); //设置签名有效时长 request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600); //执行请求 AbortMultipartUploadResult result = cosXml.AbortMultiUpload(request); Console.WriteLine(result.GetResultInfo()); } catch (COSXML.CosException.CosClientException clientEx) { Console.WriteLine("CosClientException: " + clientEx.Message); Assert.True(false); } catch (COSXML.CosException.CosServerException serverEx) { Console.WriteLine("CosServerException: " + serverEx.GetInfo()); Assert.True(false); } }
public void AbortMultiUpload() { string key = multiKey; try { InitMultipartUploadRequest initMultipartUploadRequest = new InitMultipartUploadRequest(bucket, key); //执行请求 InitMultipartUploadResult initMultipartUploadResult = cosXml.InitMultipartUpload(initMultipartUploadRequest); Console.WriteLine(initMultipartUploadResult.GetResultInfo()); string uploadId = initMultipartUploadResult.initMultipartUpload.uploadId; AbortMultipartUploadRequest request = new AbortMultipartUploadRequest(bucket, key, uploadId); //执行请求 AbortMultipartUploadResult result = cosXml.AbortMultiUpload(request); Console.WriteLine(result.GetResultInfo()); } catch (COSXML.CosException.CosClientException clientEx) { Console.WriteLine("CosClientException: " + clientEx.Message); Assert.True(false); } catch (COSXML.CosException.CosServerException serverEx) { Console.WriteLine("CosServerException: " + serverEx.GetInfo()); Assert.True(false); } }
/// 终止分片上传任务 public void AbortMultiUpload() { //.cssg-snippet-body-start:[abort-multi-upload] try { string bucket = "examplebucket-1250000000"; //存储桶,格式:BucketName-APPID string key = "exampleobject"; //对象键 string uploadId = "exampleUploadId"; //初始化分块上传返回的uploadId AbortMultipartUploadRequest request = new AbortMultipartUploadRequest(bucket, key, uploadId); //执行请求 AbortMultipartUploadResult result = cosXml.AbortMultiUpload(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 AbortMultiUpload(COSXML.CosXml cosXml, string bucket, string key, string uploadId) { try { AbortMultipartUploadRequest request = new AbortMultipartUploadRequest(bucket, key, uploadId); //设置签名有效时长 request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600); //执行请求 AbortMultipartUploadResult result = cosXml.AbortMultiUpload(request); Console.WriteLine(result.GetResultInfo()); } catch (COSXML.CosException.CosClientException clientEx) { QLog.D("XIAO", clientEx.Message); Console.WriteLine("CosClientException: " + clientEx.StackTrace); } catch (COSXML.CosException.CosServerException serverEx) { QLog.D("XIAO", serverEx.Message); Console.WriteLine("CosServerException: " + serverEx.GetInfo()); } }