本文整理汇总了C#中Amazon.S3.AmazonS3Client.DeleteBucketPolicy方法的典型用法代码示例。如果您正苦于以下问题:C# AmazonS3Client.DeleteBucketPolicy方法的具体用法?C# AmazonS3Client.DeleteBucketPolicy怎么用?C# AmazonS3Client.DeleteBucketPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Amazon.S3.AmazonS3Client
的用法示例。
在下文中一共展示了AmazonS3Client.DeleteBucketPolicy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BucketSamples
public void BucketSamples()
{
{
#region ListBuckets Sample
// Create a client
AmazonS3Client client = new AmazonS3Client();
// Issue call
ListBucketsResponse response = client.ListBuckets();
// View response data
Console.WriteLine("Buckets owner - {0}", response.Owner.DisplayName);
foreach (S3Bucket bucket in response.Buckets)
{
Console.WriteLine("Bucket {0}, Created on {1}", bucket.BucketName, bucket.CreationDate);
}
#endregion
}
{
#region BucketPolicy Sample
// Create a client
AmazonS3Client client = new AmazonS3Client();
// Put sample bucket policy (overwrite an existing policy)
string newPolicy = @"{
""Statement"":[{
""Sid"":""BasicPerms"",
""Effect"":""Allow"",
""Principal"": ""*"",
""Action"":[""s3:PutObject"",""s3:GetObject""],
""Resource"":[""arn:aws:s3:::samplebucketname/*""]
}]}";
PutBucketPolicyRequest putRequest = new PutBucketPolicyRequest
{
BucketName = "SampleBucket",
Policy = newPolicy
};
client.PutBucketPolicy(putRequest);
// Retrieve current policy
GetBucketPolicyRequest getRequest = new GetBucketPolicyRequest
{
BucketName = "SampleBucket"
};
string policy = client.GetBucketPolicy(getRequest).Policy;
Console.WriteLine(policy);
Debug.Assert(policy.Contains("BasicPerms"));
// Delete current policy
DeleteBucketPolicyRequest deleteRequest = new DeleteBucketPolicyRequest
{
BucketName = "SampleBucket"
};
client.DeleteBucketPolicy(deleteRequest);
// Retrieve current policy and verify that it is null
policy = client.GetBucketPolicy(getRequest).Policy;
Debug.Assert(policy == null);
#endregion
}
{
#region GetBucketLocation Sample
// Create a client
AmazonS3Client client = new AmazonS3Client();
// Construct request
GetBucketLocationRequest request = new GetBucketLocationRequest
{
BucketName = "SampleBucket"
};
// Issue call
GetBucketLocationResponse response = client.GetBucketLocation(request);
// View response data
Console.WriteLine("Bucket location - {0}", response.Location);
#endregion
}
{
#region PutBucket Sample
// Create a client
AmazonS3Client client = new AmazonS3Client();
// Construct request
PutBucketRequest request = new PutBucketRequest
{
//.........这里部分代码省略.........