AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Container for the parameters to the PutAcl operation.

uses the acl subresource to set the access control list (ACL) permissions for an object that already exists in a bucket

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceRequest
    Amazon.S3.Model.PutACLRequest

Namespace: Amazon.S3.Model
Assembly: AWSSDK.S3.dll
Version: 3.x.y.z

Syntax

C#
public class PutACLRequest : AmazonWebServiceRequest
         IAmazonWebServiceRequest

The PutACLRequest type exposes the following members

Constructors

NameDescription
Public Method PutACLRequest()

Properties

NameTypeDescription
Public Property AccessControlList Amazon.S3.Model.S3AccessControlList

Custom ACLs to be applied to the bucket or object.

Public Property BucketName System.String

The name of the bucket. If an object key is not specified, the ACLs are applied to the bucket.

Public Property CannedACL Amazon.S3.S3CannedACL

The canned ACL to apply to the bucket.

Public Property Key System.String

The key of an S3 object. If not specified, the ACLs are applied to the bucket.

Public Property VersionId System.String

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.

PutACL sample 1


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

// Set Canned ACL (PublicRead) for an existing item
client.PutACL(new PutACLRequest
{
    BucketName = "SampleBucket",
    Key = "Item1",
    CannedACL = S3CannedACL.PublicRead
});

// Set Canned ACL (PublicRead) for an existing item
// (This reverts ACL back to default for object)
client.PutACL(new PutACLRequest
{
    BucketName = "SampleBucket",
    Key = "Item1",
    CannedACL = S3CannedACL.Private
});

                

This example shows how to get and set ACLs on an object.

GetACL\PutACL 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 { grant },
    Owner = owner
};

// Set new ACL
PutACLResponse response = client.PutACL(new PutACLRequest
{
    BucketName = "SampleBucket",
    Key = "Item1",
    AccessControlList = acl
});

                

Version Information

.NET Standard:
Supported in: 1.3

.NET Framework:
Supported in: 4.5, 4.0, 3.5

Portable Class Library:
Supported in: Windows Store Apps
Supported in: Windows Phone 8.1
Supported in: Xamarin Android
Supported in: Xamarin iOS (Unified)
Supported in: Xamarin.Forms

Unity:
Supported Versions: 4.6 and above
Supported Platforms: Android, iOS, Standalone