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.

Returns information about the PutObjectAcl response metadata. The PutAcl operation has a void result type.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceResponse
    Amazon.S3.Model.PutACLResponse

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

Syntax

C#
public class PutACLResponse : AmazonWebServiceResponse

The PutACLResponse type exposes the following members

Constructors

NameDescription
Public Method PutACLResponse()

Properties

NameTypeDescription
Public Property ContentLength System.Int64 Inherited from Amazon.Runtime.AmazonWebServiceResponse.
Public Property HttpStatusCode System.Net.HttpStatusCode Inherited from Amazon.Runtime.AmazonWebServiceResponse.
Public Property ResponseMetadata Amazon.Runtime.ResponseMetadata Inherited from Amazon.Runtime.AmazonWebServiceResponse.

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

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

                

Version Information

.NET Core App:
Supported in: 3.1

.NET Standard:
Supported in: 2.0

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