POST Object
Description
The POST
operation adds an object to a specified bucket using HTML forms.
POST
is an alternate form of PUT
that enables
browser-based uploads as a way of putting objects in buckets. You must have
WRITE
access on a bucket to add an object to it. Amazon S3 never stores
partial objects: if you receive a successful response, you can be confident the entire
object was stored.
Amazon S3 is a distributed system. If Amazon S3 receives multiple write requests for the same object simultaneously, all but the last object written will be overwritten.
To ensure that data is not corrupted traversing 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 POST
ing an object to Amazon S3 and compare the returned
ETag
to the calculated MD5 value. The ETag only reflects
changes to the contents of an object, not its metadata.
![]() | Note |
---|---|
To configure your application to send the request headers prior to sending the
request body, use the 100-continue HTTP status code. For |
Requests
Syntax
POST /ObjectName
?acl HTTP/1.1 Host:destinationBucket
.s3.amazonaws.com User-Agent:browser_data
Accept:file_types
Accept-Language:Regions
Accept-Encoding:encoding
Accept-Charset:character_set
Keep-Alive: 300 Connection: keep-alive Content-Type: multipart/form-data; boundary=9431149156168 Content-Length:length
--9431149156168 Content-Disposition: form-data; name="key"filepath
--9431149156168 Content-Disposition: form-data; name="acl"acl
--9431149156168 Content-Disposition: form-data; name="success_action_redirect"success_redirect
--9431149156168 Content-Disposition: form-data; name="Content-Type"content_type
--9431149156168 Content-Disposition: form-data; name="x-amz-meta-uuid"uuid
--9431149156168 Content-Disposition: form-data; name="x-amz-meta-tag"metadata
--9431149156168 Content-Disposition: form-data; name="AWSAccessKeyId"access-key-id
--9431149156168 Content-Disposition: form-data; name="Policy"encoded_policy
--9431149156168 Content-Disposition: form-data; name="Signature"signature
= --9431149156168 Content-Disposition: form-data; name="file"; filename="MyFilename.jpg" Content-Type: image/jpegfile_content
--9431149156168 Content-Disposition: form-data; name="submit" Upload to Amazon S3 --9431149156168--
Request Parameters
This implementation of the operation does not use request parameters.
Request Headers
This implementation of the operation can use the following request headers in addition to the request headers common to all operations. For more information, see Common Request Headers.
Name | Description | Required | |||
---|---|---|---|---|---|
AWSAccessKeyId
|
The AWS Access Key ID of the owner of the bucket who grants an Anonymous user access for a request that satisfies the set of constraints in the Policy. Type: String Default: None Constraints: Required if a policy document is included with the request. |
Conditional |
|||
acl
|
Specifies an Amazon S3 access control list. If an invalid access control list is specified, an error is generated. For more information on ACLs, go to Amazon S3 ACLs in the Amazon Simple Storage Service Developer Guide . Type: String Default: private Valid Values: private | public-read | public-read-write | authenticated-read | bucket-owner-read | bucket-owner-full-control |
No |
|||
Cache-Control, Content-Type, Content-Disposition,
Content-Encoding
|
REST-specific headers. For more information, see PUT Object. Type: String Default: None |
No |
|||
expires
|
Number of milliseconds before expiration Type: Int Default: None |
No |
|||
file
|
File or text content. The file or text content must be the last field in the form. You cannot upload more than one file at a time. Type: File or text content Default: None |
Yes |
|||
key
|
The name of the uploaded key. To use the filename provided by the user, use the ${filename} variable. For example, if the user Betty uploads the file the file lolcatz.jpg and you specify /user/betty/${filename}, the file will be stored as /user/betty/lolcatz.jpg. For more information, go to Using Keys in the Amazon Simple Storage Service Developer Guide . Type: String Default: None |
Yes |
|||
policy
|
Security Policy describing what is permitted in the request. Requests without a security policy are considered anonymous and only work on publicly writable buckets. Type: String Default: None |
No |
|||
success_action_redirect, redirect
|
The URL to which the client is redirected upon successful upload. If success_action_redirect is not specified, Amazon S3 returns the empty document type specified in the success_action_status field. If Amazon S3 cannot interpret the URL, it acts as if the field is not present. If the upload fails, Amazon S3 displays an error and does not redirect the user to a URL. Type: String Default: None
|
No |
|||
success_action_status
|
The status code returned to the client upon successful upload if success_action_redirect is not specified. Accepts the values 200, 201, or 204 (default). If the value is set to 200 or 204, Amazon S3 returns an empty document with a 200 or 204 status code. If the value is set to 201, Amazon S3 returns an XML document with a 201 status code. If the value is not set or if it is set to an invalid value, Amazon S3 returns an empty document with a 204 status code. Type: String Default: None
|
No |
|||
x-amz-meta-*
|
Field names prefixed with Amazon S3 does not validate or use this data. For more information, see PUT Object. Type: String Default: None |
No |
|||
x-amz-security-token
|
Amazon DevPay security token. Each request that uses Amazon DevPay requires two
For more information, go to Using DevPay . Type: String Default: None |
No |
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 |
---|---|
success_action_redirect, redirect
|
The URL to which the client is redirected on successful upload. Type: String Ancestor: PostResponse |
x-amz-version-id
|
Version of the object. Type: String |
Response Elements
Name | Description |
---|---|
Bucket
|
Name of the bucket the object was stored in. Type: String Ancestor: PostResponse |
ETag
|
The entity tag is an MD5 hash of the object that you
can use to do conditional Type: String Ancestor: PostResponse |
Key
|
The entity tag is an MD5 hash of the object that you
can use to do conditional Type: String Ancestor: PostResponse |
Location
|
URI of the object. Type: String Ancestor: PostResponse |
Special Errors
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.
Examples
Sample Request
POST /Neo HTTP/1.1
Content-Length: 4
Host: quotes.s3.amazonaws.com
Date: Wed, 01 Mar 2009 12:00:00 GMT
Authorization: AWS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE=
Content-Type: text/plain
Expect: the 100-continue HTTP status code
ObjectContent
Sample Response With Versioning Suspended
The following shows a sample response when bucket versioning is suspended.
HTTP/1.1 100 Continue HTTP/1.1 200 OK x-amz-id-2: LriYPLdmOdAiIfgSm/F1YsViT1LW94/xUQxMsF7xiEb1a0wiIOIxl+zbwZ163pt7 x-amz-request-id: 0A49CE4060975EAC x-amz-version-id: default Date: Wed, 12 Oct 2009 17:50:00 GMT ETag: "1b2cf535f27731c974343645a3985328" Content-Length: 0 Connection: close Server: AmazonS3
Notice in this response the version ID is null
.
Sample Response With Versioning Enabled
The following shows a sample response when bucket versioning is enabled.
HTTP/1.1 100 Continue HTTP/1.1 200 OK x-amz-id-2: LriYPLdmOdAiIfgSm/F1YsViT1LW94/xUQxMsF7xiEb1a0wiIOIxl+zbwZ163pt7 x-amz-request-id: 0A49CE4060975EAC x-amz-version-id: 43jfkodU8493jnFJD9fjj3HHNVfdsQUIFDNsidf038jfdsjGFDSIRp Date: Wed, 01 Mar 2009 12:00:00 GMT ETag: "828ef3fdfa96f00ad9f27c383fc9ac7f" Content-Length: 0 Connection: close Server: AmazonS3