The parameters to set an access control list (ACL) on a bucket or S3 object.
You can use either CannedACLs or provide an S3AccessControlList for custom ACLs.
Declaration Syntax
C# |
public class SetACLRequest : S3Request
Members
All Members | Constructors | Methods | Properties | ||
Icon | Member | Description |
---|---|---|
SetACLRequest()()()() | Initializes a new instance of the SetACLRequest class | |
ACL |
Custom ACLs to be applied to the bucket or object.
| |
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.
If an object key is not specified, the ACLs are applied to the bucket.
| |
CannedACL |
Canned ACL to apply to the bucket or object.
| |
Equals(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.) | |
Key |
The key of an S3 object.
If not specified, the ACLs are applied to the bucket.
| |
ReadWriteTimeout |
Overrides the default HttpWebRequest ReadWriteTimeout value.
(Inherited from S3Request.) | |
RemoveCannedACL()()()() |
Resets the S3CannedACL associated with this request
| |
Timeout |
Overrides the default HttpWebRequest timeout value.
(Inherited from S3Request.) | |
ToString()()()() | (Inherited from S3Request.) | |
VersionId |
If set and an object key has been specified, the ACLs are applied
to the specific version of the object.
This property is ignored if the ACL is to be set on a Bucket.
| |
WithACL(S3AccessControlList) | Obsolete.
Sets the custom ACLs to be applied to the bucket or object.
| |
WithBucketName(String) | Obsolete.
The name of the bucket.
If an object key is not specified, the ACLs are applied to the bucket.
| |
WithCannedACL(S3CannedACL) | Obsolete.
Sets a canned ACL to apply to the bucket or object.
| |
WithInputStream(Stream) | Obsolete.
Sets an input stream for the request; content for the request will be read from the stream.
(Inherited from S3Request.) | |
WithKey(String) | Obsolete.
Sets the key of an S3 object.
If not specified, the ACLs are applied to the 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.) | |
WithVersionId(String) | Obsolete.
If set and an object key has been specified, the ACLs are applied
to the specific version of the object.
This property is ignored if the ACL is to be set on a Bucket.
|
Examples
This example shows how to set a canned ACL on an object, first to PublicRead, then back to Private.
CopySetACL sample 1
// Create a client AmazonS3Client client = new AmazonS3Client(); // Set Canned ACL (PublicRead) for an existing item client.SetACL(new SetACLRequest { BucketName = "SampleBucket", Key = "Item1", CannedACL = S3CannedACL.PublicRead }); // Set Canned ACL (PublicRead) for an existing item // (This reverts ACL back to default for object) client.SetACL(new SetACLRequest { BucketName = "SampleBucket", Key = "Item1", CannedACL = S3CannedACL.Private });
This example shows how to get and set ACLs on an object.
CopyGetACL\SetACL samples
// Create a client AmazonS3Client client = new AmazonS3Client(); // Retrieve ACL for object S3AccessControlList acl = client.GetACL(new GetACLRequest { BucketName = "SampleBucket", Key = "Item1", }).AccessControlList; // Retrieve owner Owner owner = acl.Owner; // Describe grant S3Grant grant = new S3Grant { Grantee = new S3Grantee { EmailAddress = "sample@example.com" }, Permission = S3Permission.WRITE_ACP }; // Create new ACL S3AccessControlList newAcl = new S3AccessControlList { Grants = new List<S3Grant> { grant }, Owner = owner }; // Set new ACL SetACLResponse response = client.SetACL(new SetACLRequest { BucketName = "SampleBucket", Key = "Item1", ACL = acl });