private void PutBucket() { try { PutBucketRequest request = new PutBucketRequest(bucket); QCloudServer.SetRequestACLData(request); //执行请求 PutBucketResult result = cosXml.PutBucket(request); Assert.AreEqual(result.httpCode, 200); isBucketCreatedByTest = true; } catch (COSXML.CosException.CosClientException clientEx) { Console.WriteLine("CosClientException: " + clientEx.Message); Assert.Fail(); } catch (COSXML.CosException.CosServerException serverEx) { Console.WriteLine("CosServerException: " + serverEx.GetInfo()); if (serverEx.statusCode != 409) { Assert.Fail(); } } }
private void PutBucketACL() { try { PutBucketACLRequest request = new PutBucketACLRequest(bucket); request.SetQueryParameter("time", TimeUtils.GetCurrentTime(TimeUnit.Seconds).ToString()); request.SetRequestHeader("custom", "value1"); request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.Seconds), 600, new List <string>() { "custome" }, new List <string>() { "time" }); QCloudServer.SetRequestACLData(request); //执行请求 PutBucketACLResult result = cosXml.PutBucketACL(request); Assert.AreEqual(result.httpCode, 200); } catch (COSXML.CosException.CosClientException clientEx) { Console.WriteLine("CosClientException: " + clientEx.Message); Assert.Fail(); } catch (COSXML.CosException.CosServerException serverEx) { Console.WriteLine("CosServerException: " + serverEx.GetInfo()); Assert.Fail(); } }