Amazon Simple Storage Service
API Reference (API Version 2006-03-01)
Did this page help you?  Yes | No |  Tell us about it...
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.

PUT Object acl

Description

This implementation of the PUT operation uses the acl subresource to set the access control list (ACL) permissions for an object that already exists in a bucket. You must have WRITE_ACP permission to set the ACL of an object.

You can use one of the following two ways to set an object's permissions:

  • Specify the ACL in the request body, or

  • Specify permissions using request headers

    Depending on your application needs, you may choose to set the ACL on an object using either the request body or the headers. For example, if you have an existing application that updates an object ACL using the request body, then you can continue to use that approach.

    Versioning

    The ACL of an object is set at the object version level. By default, PUT sets the ACL of the current version of an object. To set the ACL of a different version, use the versionId subresource.

    To see sample requests that use versioning, see Sample Request: Setting the ACL of a specified object version.

    Requests

    Syntax

    The following request shows the syntax for sending the ACL in the request body. If you want to use headers to specify the permissions for the object, you cannot send the ACL in the request body. Instead, see the Request Headers section for a list of headers you can use.

    PUT /ObjectName?acl HTTP/1.1
    Host: BucketName.s3.amazonaws.com
    Date: date
    Authorization: authorization string (see Authenticating Requests (AWS Signature Version 4))
    
    <AccessControlPolicy>
      <Owner>
        <ID>ID</ID>
        <DisplayName>EmailAddress</DisplayName>
      </Owner>
      <AccessControlList>
        <Grant>
          <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
            <ID>ID</ID>
            <DisplayName>EmailAddress</DisplayName>
          </Grantee>
          <Permission>Permission</Permission>
        </Grant>
        ...
      </AccessControlList>
    </AccessControlPolicy> 

    Note

    The syntax shows some of the request headers. For a complete list see the Request Headers section.

    Request Parameters

    This implementation of the operation does not use request parameters.

    Request Headers

    You can use the following request headers in addition to the Common Request Headers.

    These headers enable you to set access permissions using one of the following methods:

    • Specify canned ACL, or

    • Specify the permission for each grantee explicitly

    Amazon S3 supports a set of predefined ACLs, known as canned ACLs. Each canned ACL has a predefined a set of grantees and permissions. For more information, see Canned ACL. To grant access permissions by specifying canned ACLs, you use the following header and specify the canned ACL name as its value. If you use this header, you cannot use other access control-specific headers in your request.

    Name Description Required
    x-amz-acl

    The canned ACL to apply to the object. For more information, go to Canned ACL in the Amazon Simple .

    Type: String

    Valid Values: private | public-read | public-read-write | authenticated-read | bucket-owner-read | bucket-owner-full-control

    Default: private

    No

    If you need to grant individualized access permissions on an object, you can use the following x-amz-grant-permission headers. When using these headers you specify explicit access permissions and grantees (AWS accounts or Amazon S3 groups) who will receive the permission. If you use these ACL specific headers, you cannot use x-amz-acl header to set a canned ACL.

    Note

    Each of the following request headers maps to specific permissions Amazon S3 supports in an ACL. For more information, go to Access Control List (ACL) Overview.

    Name Description Required
    x-amz-grant-read

    Allows the specified grantee to list the objects in the bucket.

    Type: String

    Default: None

    Constraints: None

    No
    x-amz-grant-write

    Not applicable when granting access permissions on objects. You can use this when granting access permissions on buckets.

    Type: String

    Default: None

    Constraints: None

    No
    x-amz-grant-read-acp

    Allows the specified grantee to read the bucket ACL.

    Type: String

    Default: None

    Constraints: None

    No
    x-amz-grant-write-acp

    Allows the specified grantee to write the ACL for the applicable bucket.

    Type: String

    Default: None

    Constraints: None

    No
    x-amz-grant-full-control

    Allows the specified grantee the READ, WRITE, READ_ACP, and WRITE_ACP permissions on the bucket.

    Type: String

    Default: None

    Constraints: None

    No

    For each of these headers, the value is a comma-separated list of one or more grantees. You specify each grantee as a type=value pair, where the type can be one of the following:

    • emailAddress — if value specified is the email address of an AWS account

    • id — if value specified is the canonical user ID of an AWS account

    • uri — if granting permission to a predefined group.

    For example, the following x-amz-grant-read header grants list objects permission to the two AWS accounts identified by their email addresses.

    x-amz-grant-read: emailAddress="xyz@amazon.com", emailAddress="abc@amazon.com"

    For more information, go to Access Control List (ACL) Overview.

    Request Elements

    If you decide to use the request body to specify an ACL, you must use the following elements.

    Note

    If you use the request body, you cannot use the request headers to set an ACL.

    Name Description
    AccessControlList

    Container for ACL information

    Type: Container

    Ancestors: AccessControlPolicy

    AccessControlPolicy

    Contains the elements that set the ACL permissions for an object per grantee

    Type: Container

    Ancestors: None

    DisplayName

    Screen name of the bucket owner

    Type: String

    Ancestors: AccessControlPolicy.Owner

    Grant

    Container for the grantee and his or her permissions

    Type: Container

    Ancestors: AccessControlPolicy.AccessControlList

    Grantee

    The subject whose permissions are being set.

    Type: String

    Valid Values: DisplayName | EmailAddress | AuthenticatedUser. For more information, see Grantee Values.

    Ancestors: AccessControlPolicy.AccessControlList.Grant

    ID

    ID of the bucket owner, or the ID of the grantee

    Type: String

    Ancestors: AccessControlPolicy.Owner or AccessControlPolicy.AccessControlList.Grant

    Owner

    Container for the bucket owner's display name and ID

    Type: Container

    Ancestors: AccessControlPolicy

    Permission

    Specifies the permission given to the grantee

    Type: String

    Valid Values: FULL_CONTROL | WRITE | WRITE_ACP | READ | READ_ACP

    Ancestors: AccessControlPolicy.AccessControlList.Grant

    Grantee Values

    You can specify the person (grantee) to whom you're assigning access rights (using request elements) in the following ways:

    • By the person's ID:

      <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID>ID</ID><DisplayName>GranteesEmail</DisplayName>
      </Grantee>

      DisplayName is optional and ignored in the request.

    • By Email address:

      <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AmazonCustomerByEmail"><EmailAddress>Grantees@email.com</EmailAddress>lt;/Grantee>

      The grantee is resolved to the CanonicalUser and, in a response to a GET Object acl request, appears as the CanonicalUser.

    • By URI:

      <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group"><URI>http://acs.amazonaws.com/groups/global/AuthenticatedUsers</URI></Grantee>

    Responses

    Response Headers

    This implementation of the operation can include the following response headers in addition to the response headers common to all responses. For more information, see Common Response Headers.

    Name Description
    x-amz-version-id

    Version of the object whose ACL is being set.

    Type: String

    Default: None

    Response Elements

    This operation does not return response elements.

    Special Errors

    This operation does not return special errors. For general information about Amazon S3 errors and a list of error codes, see Error Responses.

    Examples

    Sample Request

    The following request grants access permission to an existing object. The request specifies the ACL in the body. In addition to granting full control to the object owner, the XML specifies full control to an AWS account identified by its canonical user ID.

    PUT /my-image.jpg?acl HTTP/1.1
    Host: bucket.s3.amazonaws.com
    Date: Wed, 28 Oct 2009 22:32:00 GMT
    Authorization: authorization string
    Content-Length: 124
    
    <AccessControlPolicy>
      <Owner>
        <ID>75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a</ID>
        <DisplayName>CustomersName@amazon.com</DisplayName>
      </Owner>
      <AccessControlList>
        <Grant>
          <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
            <ID>75aa57f09aa0c8caeab4f8c24e99d10f8e7faeeExampleCanonicalUserID</ID>
            <DisplayName>CustomerName@amazon.com</DisplayName>
          </Grantee>
          <Permission>FULL_CONTROL</Permission>
        </Grant>
      </AccessControlList>
    </AccessControlPolicy>

    Sample Response

    The following shows a sample response when versioning on the bucket is enabled.

    HTTP/1.1 200 OK
    x-amz-id-2: eftixk72aD6Ap51T9AS1ed4OpIszj7UDNEHGran
    x-amz-request-id: 318BC8BC148832E5
    x-amz-version-id: 3/L4kqtJlcpXrof3vjVBH40Nr8X8gdRQBpUMLUo
    Date: Wed, 28 Oct 2009 22:32:00 GMT
    Last-Modified: Sun, 1 Jan 2006 12:00:00 GMT
    Content-Length: 0
    Connection: close
    Server: AmazonS3

    Sample Request: Setting the ACL of a specified object version

    The following request sets the ACL on the specified version of the object.

    PUT /my-image.jpg?acl&versionId=3HL4kqtJlcpXroDTDmJ+rmSpXd3dIbrHY+MTRCxf3vjVBH40Nrjfkd HTTP/1.1
    Host: bucket.s3.amazonaws.com
    Date: Wed, 28 Oct 2009 22:32:00 GMT
    Authorization: authorization string
    Content-Length: 124
     
    <AccessControlPolicy>
      <Owner>
        <ID>75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a</ID>
        <DisplayName>mtd@amazon.com</DisplayName>
      </Owner>
      <AccessControlList>
        <Grant>
          <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
            <ID>75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a</ID>
            <DisplayName>mtd@amazon.com</DisplayName>
          </Grantee>
          <Permission>FULL_CONTROL</Permission>
        </Grant>
      </AccessControlList>
    </AccessControlPolicy>

    Sample Response

    HTTP/1.1 200 OK
    x-amz-id-2: eftixk72aD6Ap51u8yU9AS1ed4OpIszj7UDNEHGran
    x-amz-request-id: 318BC8BC148832E5
    x-amz-version-id: 3/L4kqtJlcpXro3vjVBH40Nr8X8gdRQBpUMLUo
    Date: Wed, 28 Oct 2009 22:32:00 GMT
    Last-Modified: Sun, 1 Jan 2006 12:00:00 GMT
    Content-Length: 0
    Connection: close
    Server: AmazonS3

    Sample Request: Access permissions specified using headers

    The following request uses ACL-specific request headers, x-amz-acl, and specifies a canned ACL (public_read) to grant object read access to everyone.

    PUT ExampleObject.txt?acl HTTP/1.1
    Host: examplebucket.s3.amazonaws.com
    x-amz-acl: public-read
    Accept: */*
    Authorization: authorization string
    Host: s3.amazonaws.com
    Connection: Keep-Alive

    Sample Response

    HTTP/1.1 200 OK
    x-amz-id-2: w5YegkbG6ZDsje4WK56RWPxNQHIQ0CjrjyRVFZhEJI9E3kbabXnBO9w5G7Dmxsgk
    x-amz-request-id: C13B2827BD8455B1
    Date: Sun, 29 Apr 2012 23:24:12 GMT
    Content-Length: 0
    Server: AmazonS3