public static async Task UploadObjectAsync(this CosServerWrapObject client,
                                            string bucketName,
                                            string objectKey,
                                            Stream data)
 {
     await client.CosXmlServer.ExecuteAsync <PutObjectResult>(new PutObjectRequest(bucketName, objectKey,
                                                                                   await data.ToBytesAsync()));
 }
        public static async Task <Stream> DownloadObjectAsync(this CosServerWrapObject client,
                                                              string bucketName,
                                                              string objectKey)
        {
            var result =
                await client.CosXmlServer.ExecuteAsync <GetObjectBytesResult>(
                    new GetObjectBytesRequest(bucketName, objectKey));

            return(new MemoryStream(result.content));
        }
        public static async Task <bool> CheckBucketIsExistAsync(this CosServerWrapObject client, string bucketName)
        {
            try
            {
                var result = await client.CosXmlServer.ExecuteAsync <HeadBucketResult>(new HeadBucketRequest(bucketName));

                return(result.IsSuccessful());
            }
            catch (CosServerException exception)
            {
                if (exception.statusCode == 404)
                {
                    return(false);
                }

                throw;
            }
        }
 public static async Task DeleteObjectAsync(this CosServerWrapObject client,
                                            string bucketName,
                                            string objectKey)
 {
     await client.CosXmlServer.ExecuteAsync <DeleteObjectResult>(new DeleteObjectRequest(bucketName, objectKey));
 }
 public static async Task CreateBucketAsync(this CosServerWrapObject client, string bucketName)
 {
     await client.CosXmlServer.ExecuteAsync <PutBucketResult>(new PutBucketRequest(bucketName));
 }