PUT Object

The PUT request operation adds an object to a bucket.

The response indicates that the object has been successfully stored. Amazon S3 never stores partial objects: if you receive a successful response, then you can be confident that the entire object was stored.

To ensure data is not corrupted over the network, use the Content-MD5 header. When you use the Content-MD5 header, Amazon S3 checks the object against the provided MD5 value. If they do not match, Amazon S3 returns an error. Additionally, you can calculate the MD5 while putting an object to Amazon S3 and compare the returned Etag to the calculated MD5.

If an object already exists in a bucket, the new object will overwrite it because Amazon S3 stores the last write request. However, Amazon S3 is a distributed system. If it receives multiple write requests for the same object nearly simultaneously, all of the objects might be stored, even though only one wins in the end. Amazon S3 does not provide object locking; if you need this, make sure to build it into your application layer.

If you specify a location constraint when creating a bucket, all objects added to the bucket are stored in the bucket's location. For example, if you specify a Europe (EU) location constraint for a bucket, all of that bucket's objects are stored in Europe. For more information on location constraints, see Location Selection.

[Note]Note

To configure your application to send the request headers prior to sending the request body, use 100-continue. For PUT operations, this helps you avoid sending the message body if the message is rejected based on the headers (e.g., authentication failure or redirect). For more information on 100-continue, go to Section 8.2.3 of http://www.ietf.org/rfc/rfc2616.txt.

Example

This example writes some text and metadata into the "Neo" object in the "quotes" bucket.

Sample Request

PUT /Neo HTTP/1.1

x-amz-meta-family: Anderson

Content-Length: 4

Host: quotes.s3.amazonaws.com

Date: Wed, 01 Mar  2006 12:00:00 GMT

Authorization: AWS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE=

Content-Type: text/plain

Expect: 100-continue



woah

Sample Response

HTTP/1.1 100 Continue

HTTP/1.1 200 OK

x-amz-id-2: LriYPLdmOdAiIfgSm/F1YsViT1LW94/xUQxMsF7xiEb1a0wiIOIxl+zbwZ163pt7

x-amz-meta-family: Anderson

x-amz-request-id: 0A49CE4060975EAC

Date: Wed, 01 Mar  2006 12:00:00 GMT

ETag: "828ef3fdfa96f00ad9f27c383fc9ac7f"

Content-Length: 0

Connection: close

Server: AmazonS3

The data to be stored in the object is sent in the request body.

You must have WRITE access to the bucket to add an object.