HTTPPOSTExamples
Upload Examples (AWS Signature Version 2)****
Topics
Note
The request authentication discussed in this section is based on AWS Signature Version 2, a protocol for authenticating inbound API requests to AWS services.
Amazon S3 now supports Signature Version 4, a protocol for authenticating inbound API requests to AWS services, in all AWS regions. At this time, AWS regions created before January 30, 2014 will continue to support the previous protocol, Signature Version 2. Any new regions after January 30, 2014 will support only Signature Version 4 and therefore all requests to those regions must be made with Signature Version 4. For more information, see Examples: Browser-Based Upload using HTTP POST (Using AWS Signature Version 4) in the Amazon Simple Storage Service API Reference.
File Upload
This example shows the complete process for constructing a policy and form that can be used to upload a file attachment.
Policy and Form Construction
The following policy supports uploads to Amazon S3 for the johnsmith bucket.
This policy requires the following:
- The upload must occur before 12:00 UTC on December 1, 2007.
- The content must be uploaded to the johnsmith bucket.
- The key must start with "user/eric/".
- The ACL is set to public-read.
- The success_action_redirect is set to https://johnsmith.s3.us-west-1.amazonaws.com/successful_upload.html.
- The object is an image file.
- The x-amz-meta-uuid tag must be set to 14365123651274.
- The x-amz-meta-tag can contain any value.
The following is a Base64-encoded version of this policy.
Using your credentials create a signature, for example 0RavWzkygo6QX9caELEqKi9kDbU=
is the signature for the preceding policy document.
The following form supports a POST request to the johnsmith.net bucket that uses this policy.
Sample Request
This request assumes that the image uploaded is 117,108 bytes; the image data is not included.
Sample Response
Text Area Upload
Topics
The following example shows the complete process for constructing a policy and form to upload a text area. Uploading a text area is useful for submitting user-created content, such as blog postings.
Policy and Form Construction
The following policy supports text area uploads to Amazon S3 for the johnsmith bucket.
This policy requires the following:
- The upload must occur before 12:00 GMT on 2007-12-01.
- The content must be uploaded to the johnsmith bucket.
- The key must start with "user/eric/".
- The ACL is set to public-read.
- The success_action_redirect is set to https://johnsmith.s3.us-west-1.amazonaws.com/new_post.html.
- The object is HTML text.
- The x-amz-meta-uuid tag must be set to 14365123651274.
- The x-amz-meta-tag can contain any value.
Following is a Base64-encoded version of this policy.
Using your credentials, create a signature. For example, qA7FWXKq6VvU68lI9KdveT1cWgF=
is the signature for the preceding policy document.
The following form supports a POST request to the johnsmith.net bucket that uses this policy.
Sample Request
This request assumes that the image uploaded is 117,108 bytes; the image data is not included.