| « PreviousNext » | |
![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
This implementation of the PUT operation uses the policy
subresource to add to or replace a policy on a bucket. If the bucket already has a
policy, the one in this request completely replaces it. To perform this operation, you
must be the bucket owner.
If you are not the bucket owner but have PutBucketPolicy permissions
on the bucket, Amazon S3 returns a 405 Method Not Allowed. In all
other cases for a PUT bucket policy request that is not from the bucket owner, Amazon S3
returns 403 Access Denied. There are restrictions about who can create
bucket policies and which objects in a bucket they can apply to. For more information,
go to Using Bucket Policies.
PUT /?policy HTTP/1.1 Host:BucketName.s3.amazonaws.com Date:dateAuthorization:signatureValuePolicy written in JSON
This implementation of the operation does not use request parameters.
This implementation of the operation uses only request headers that are common to all operations. For more information, see Common Request Headers.
The body is a JSON string containing the policy contents containing the policy statements.
This implementation of the operation uses only response headers that are common to most responses. For more information, see Common Response Headers.
PUT response elements return whether the operation succeeded
or not.
This implementation of the operation does not return special errors. For general information about Amazon S3 errors and a list of error codes, see Error Responses.
The following request shows the PUT individual policy request
for the bucket.
PUT /?policy HTTP/1.1
Host: bucket.s3.amazonaws.com
Date: Tue, 04 Apr 2010 20:34:56 GMT
Authorization: AWS AKIAIOSFODNN7EXAMPLE:0RQf4/cRonhpaBX5sCYVf1bNRuU=
{
"Version":"2008-10-17",
"Id":"aaaa-bbbb-cccc-dddd",
"Statement" : [
{
"Effect":"Allow",
"Sid":"1",
"Principal" : {
"AWS":["111122223333","444455556666"]
},
"Action":["s3:*"],
"Resource":"arn:aws:s3:::bucket/*"
}
]
}
HTTP/1.1 204 No Content x-amz-id-2: Uuag1LuByR5Onimru9SAMPLEAtRPfTaOFg== x-amz-request-id: 656c76696e6727732SAMPLE7374 Date: Tue, 04 Apr 2010 20:34:56 GMT Connection: keep-alive Server: AmazonS3