AWS SDK for .NET Documentation
PutBucketPolicyRequest Class
AmazonAmazon.S3.ModelPutBucketPolicyRequest Did this page help you?   Yes   No    Tell us about it...
The parameters to set or update policy on a bucket.
Declaration Syntax
C#
public class PutBucketPolicyRequest : S3Request
Members
All MembersConstructorsMethodsProperties



IconMemberDescription
PutBucketPolicyRequest()()()()
Initializes a new instance of the PutBucketPolicyRequest class

AddHeader(String, String)
Adds the header to the collection of headers for the request.
(Inherited from S3Request.)
AddHeaders(NameValueCollection)
Adds all of the specified key/value pairs into the request headers collection.
(Inherited from S3Request.)
BucketName
The name of the bucket.

Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
GetHashCode()()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetType()()()()
Gets the type of the current instance.
(Inherited from Object.)
InputStream
Input stream for the request; content for the request will be read from the stream.
(Inherited from S3Request.)
Policy
The policy to be set on the bucket. This is the JSON string representing the policy that will be applied to the S3 Bucket.

ReadWriteTimeout
Overrides the default HttpWebRequest ReadWriteTimeout value.
(Inherited from S3Request.)
Timeout
Overrides the default HttpWebRequest timeout value.
(Inherited from S3Request.)
ToString()()()() (Inherited from S3Request.)
WithBucketName(String) Obsolete.
Sets the name of the bucket.

WithInputStream(Stream) Obsolete.
Sets an input stream for the request; content for the request will be read from the stream.
(Inherited from S3Request.)
WithPolicy(String) Obsolete.
Sets the policy to be set on the bucket. This is the JSON string representing the policy that will be applied to the S3 Bucket.

WithReadWriteTimeout(Int32) Obsolete.
Overrides the default HttpWebRequest ReadWriteTimeout value.
(Inherited from S3Request.)
WithTimeout(Int32) Obsolete.
Overrides the default HttpWebRequest timeout value.
(Inherited from S3Request.)
Examples

This example shows how to Get, Put and Delete bucket policies.

CopyBucketPolicy samples
                // Create a client
                AmazonS3Client client = new AmazonS3Client();

                // Put sample bucket policy (overwrite an existing policy)
                string newPolicy = @"{ 
    ""Statement"":[{ 
    ""Sid"":""BasicPerms"", 
    ""Effect"":""Allow"", 
    ""Principal"": { ""AWS"": ""*"" }, 
    ""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);*/
Inheritance Hierarchy
Object
S3Request
 PutBucketPolicyRequest

Assembly: AWSSDK (Module: AWSSDK) Version: 1.5.60.0 (1.5.60.0)