Exemplo n.º 1
0
        public static void AsynCompleteMultiUpload(COSXML.CosXml cosXml, string bucket, string key, string uploadId, Dictionary <int, string> partNumberAndEtags)
        {
            CompleteMultiUploadRequest request = new CompleteMultiUploadRequest(bucket, key, uploadId);

            //设置签名有效时长
            request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600);

            //设置已上传的parts
            request.SetPartNumberAndETag(partNumberAndEtags);

            //执行请求
            cosXml.CompleteMultiUpload(request, delegate(CosResult result)
            {
                CompleteMultiUploadResult getObjectResult = result as CompleteMultiUploadResult;
                Console.WriteLine(getObjectResult.GetResultInfo());
                QLog.D("XIAO", result.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());
                }
            });
        }
Exemplo n.º 2
0
        public static void CompleteMultiUpload(COSXML.CosXml cosXml, string bucket, string key, string uploadId, Dictionary <int, string> partNumberAndEtags)
        {
            try
            {
                CompleteMultiUploadRequest request = new CompleteMultiUploadRequest(bucket, key, uploadId);
                //设置签名有效时长
                request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), 600);

                //设置已上传的parts
                request.SetPartNumberAndETag(partNumberAndEtags);

                //执行请求
                CompleteMultiUploadResult result = cosXml.CompleteMultiUpload(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());
            }
        }