

# Browser-Based Uploads Using POST (AWS Signature Version 4)
<a name="sigv4-UsingHTTPPOST"></a>

This section discusses how to upload files directly to Amazon S3 through a browser using HTTP POST requests. It also contains information about how to use the AWS Amplify JavaScript library for browser-based file uploads to Amazon S3.

**Topics**
+ [

# POST Object
](RESTObjectPOST.md)
+ [

# POST Object restore
](RESTObjectPOSTrestore.md)
+ [

## Browser-Based Uploads Using HTTP POST
](#sigv4-UsingHTTPPOST-how-to)
+ [

## Calculating a Signature
](#sigv4-post-signature-calc)
+ [

# Creating an HTML Form (Using AWS Signature Version 4)
](sigv4-HTTPPOSTForms.md)
+ [

# POST Policy
](sigv4-HTTPPOSTConstructPolicy.md)
+ [

# Example: Browser-Based Upload using HTTP POST (Using AWS Signature Version 4)
](sigv4-post-example.md)
+ [

# Browser-based uploads to Amazon S3 using the AWS Amplify library
](browser-based-uploads-aws-amplify.md)

# POST Object
<a name="RESTObjectPOST"></a>

## Description
<a name="RESTObjectPOST-description"></a>

The `POST` operation adds an object to a specified bucket by using HTML forms. `POST` is an alternate form of `PUT` that enables browser-based uploads as a way of putting objects in buckets. Parameters that are passed to `PUT` through HTTP headers are instead passed as form fields to `POST` in the multipart/form-data encoded message body. To add an object to a bucket, you must have `WRITE` access on the bucket. Amazon S3 never stores partial objects. If you receive a successful response, you can be confident that the entire object was stored.

Amazon S3 is a distributed system. Unless you've enabled versioning for a bucket, if Amazon S3 receives multiple write requests for the same object simultaneously, only the last version of the object written is stored.

To ensure that data is not corrupted while traversing the network, use the `Content-MD5` form field. When you use this form field, 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 value while posting an object to Amazon S3 and compare the returned `ETag` to the calculated MD5 value. The ETag reflects only changes to the contents of an object, not its metadata.

**Note**  
To configure your application to send the request headers before sending the request body, use the HTTP status code 100 (Continue). For `POST` operations, using this status code helps you avoid sending the message body if the message is rejected based on the headers (for example, because of an authentication failure or redirect). For more information about the HTTP status code 100 (Continue), go to Section 8.2.3 of [http://www.ietf.org/rfc/rfc2616.txt](http://www.ietf.org/rfc/rfc2616.txt).

Amazon S3 automatically encrypts all new objects that are uploaded to an S3 bucket. The encryption setting of an uploaded object depends on the default encryption configuration of the destination bucket. By default, all buckets have a default encryption configuration that uses server-side encryption with Amazon S3 managed keys (SSE-S3). 

If the destination bucket has an encryption configuration that uses server-side encryption with an AWS Key Management Service (AWS KMS) key (SSE-KMS), dual-layer server-side encryption with an AWS KMS key (DSSE-KMS), or a customer-provi ded encryption key (SSE-C), Amazon S3 uses the corresponding KMS key or customer-provided key to encrypt the uploaded object. When uploading an object, if you want to change the encryption setting of the uploaded object, you can specify the type of server-side encryption. You can configure SSE-S3, SSE-KMS, DSSE-KMS, or SSE-C. For more information, see [Protecting data using server-side encryption](https://docs.aws.amazon.com/AmazonS3/latest/userguide/serv-side-encryption.html) in the *Amazon Simple Storage Service User Guide*.

**Important**  
When constructing your request, make sure that the `file` field is the last field in the form.

# Versioning
<a name="postVersions"></a>

If you enable versioning for a bucket, `POST` automatically generates a unique version ID for the object being added. Amazon S3 returns this ID in the response by using the `x-amz-version-id` response header. 

If you suspend versioning for a bucket, Amazon S3 always uses `null` as the version ID of the object stored in a bucket. 

For more information about returning the versioning state of a bucket, see [GET Bucket (Versioning Status)](API_GetBucketVersioning.md).

Amazon S3 is a distributed system. If you enable versioning for a bucket and Amazon S3 receives multiple write requests for the same object simultaneously, all versions of the object are stored. 

To see sample requests that use versioning, see [Sample Request](RESTObjectPOST.md#ExampleVersionObjectPost).

## Requests
<a name="RESTObjectPOST-requests"></a>

### Syntax
<a name="RESTObjectPOST-requests-syntax"></a>

```
 1. POST / HTTP/1.1
 2. Host: destinationBucket.s3.amazonaws.com
 3. User-Agent: browser_data
 4. Accept: file_types
 5. Accept-Language: Regions
 6. Accept-Encoding: encoding
 7. Accept-Charset: character_set
 8. Keep-Alive: 300
 9. Connection: keep-alive
10. Content-Type: multipart/form-data; boundary=9431149156168
11. Content-Length: length
12. 
13. --9431149156168
14. Content-Disposition: form-data; name="key"
15. 
16. acl
17. --9431149156168
18. Content-Disposition: form-data; name="tagging"
19. 
20. <Tagging><TagSet><Tag><Key>Tag Name</Key><Value>Tag Value</Value></Tag></TagSet></Tagging>
21. --9431149156168
22. Content-Disposition: form-data; name="success_action_redirect"
23. 
24. success_redirect
25. --9431149156168
26. Content-Disposition: form-data; name="Content-Type"
27. 
28. content_type
29. --9431149156168
30. Content-Disposition: form-data; name="x-amz-meta-uuid"
31. 
32. uuid
33. --9431149156168
34. Content-Disposition: form-data; name="x-amz-meta-tag"
35. 
36. metadata
37. --9431149156168
38. Content-Disposition: form-data; name="AWSAccessKeyId"
39. 
40. access-key-id
41. --9431149156168
42. Content-Disposition: form-data; name="Policy"
43. 
44. encoded_policy
45. --9431149156168
46. Content-Disposition: form-data; name="Signature"
47. 
48. signature=
49. --9431149156168
50. Content-Disposition: form-data; name="file"; filename="MyFilename.jpg"
51. Content-Type: image/jpeg
52. 
53. file_content
54. --9431149156168
55. Content-Disposition: form-data; name="submit"
56. 
57. Upload to Amazon S3
58. --9431149156168--
```

### Request Parameters
<a name="RESTObjectPOST-requests-request-parameters"></a>

This implementation of the operation does not use request parameters.

### Form Fields
<a name="RESTObjectPOST-requests-form-fields"></a>

This operation can use the following form fields.


| 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 |  The specified Amazon S3 access control list (ACL). If the specified ACL is not valid, an error is generated. For more information about ACLs, see [Access control list (ACL) overview](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html) in the *Amazon Simple Storage Service User Guide*.  Type: String Default: private  Valid Values: `private \| public-read \| public-read-write \| aws-exec-read \| authenticated-read \| bucket-owner-read \| bucket-owner-full-control `   |  No  | 
| Cache-Control, Content-Type, Content-Disposition, Content-Encoding, Expires |  The REST-specific headers. For more information, see [PutObject](API_PutObject.md). Type: String Default: None  |  No  | 
| file |  The 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 file name provided by the user, use the `${filename}` variable. For example, if a user named Mary uploads the file `example.jpg` and you specify `/user/mary/${filename}`, the key name is `/user/mary/example.jpg`. For more information, see [Object key and metadata](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html) in the *Amazon Simple Storage Service User Guide*. Type: String Default: None  |  Yes  | 
| policy |  The security policy that describes what is permitted in the request. Requests without a security policy are considered anonymous and work only on publicly writable buckets. For more information, see [HTML forms](https://docs.aws.amazon.com/AmazonS3/latest/userguide/HTTPPOSTForms.html) and [Upload examples](https://docs.aws.amazon.com/AmazonS3/latest/userguide/HTTPPOSTExamples.html) in the *Amazon Simple Storage Service User Guide*.  Type: String Default: None Constraints: A security policy is required if the bucket is not publicly writable.  |  Conditional  | 
| success\$1action\$1redirect, redirect |  The URL to which the client is redirected upon a 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  The `redirect` field name is deprecated, and support for the `redirect` field name will be removed in the future.    |  No  | 
| success\$1action\$1status |  If you don't specify `success_action_redirect`, the status code is returned to the client when the upload succeeds. This field accepts the values `200`, `201`, or `204` (the 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 a value that is not valid, Amazon S3 returns an empty document with a 204 status code.  Type: String Default: None  |  No  | 
| tagging |  The specified set of tags to add to the object. To add tags, use the following encoding scheme.  <pre><Tagging><br />  <TagSet><br />    <Tag><br />      <Key>TagName</Key><br />      <Value>TagValue</Value><br />    </Tag><br />    ...<br />  </TagSet><br /></Tagging></pre> For more information, see [Object tagging](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-tagging.html) in the *Amazon Simple Storage Service User Guide*. Type: String Default: None  |  No  | 
| x-amz-storage-class |  The storage class to use for storing the object. If you don't specify a class, Amazon S3 uses the default storage class, `STANDARD`. Amazon S3 supports other storage classes. For more information, see [Storage classes](https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-class-intro.html) in the *Amazon Simple Storage Service User Guide*.  Type: String Default: `STANDARD` Valid values: `REDUCED_REDUNDANCY` \$1`EXPRESS_ONEZONE` \$1 `DEEP_ARCHIVE` \$1 `GLACIER` \$1 `GLACIER_IR` \$1 `INTELLIGENT_TIERING` \$1 `ONEZONE_IA` \$1 `STANDARD` \$1 `STANDARD_IA`   |  No  | 
| x-amz-meta-\$1 |  Headers starting with this prefix are user-defined metadata. Each one is stored and returned as a set of key-value pairs. Amazon S3 doesn't validate or interpret user-defined metadata. For more information, see [PutObject](API_PutObject.md). Type: String Default: None  |  No  | 
| x-amz-security-token |  The Amazon DevPay security token.  Each request that uses Amazon DevPay requires two `x-amz-security-token` form fields: one for the product token and one for the user token. Type: String Default: None  |  No  | 
| x-amz-signature |  (AWS Signature Version 4) The HMAC-SHA256 hash of the security policy. Type: String Default: None  |  Conditional  | 
| x-amz-website-redirect-location  |  If the bucket is configured as a website, this field redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata. For information about object metadata, see [Object key and metadata](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html) in the *Amazon Simple Storage Service User Guide*. In the following example, the request header sets the redirect to an object (`anotherPage.html`) in the same bucket: `x-amz-website-redirect-location: /anotherPage.html` In the following example, the request header sets the object redirect to another website: `x-amz-website-redirect-location: http://www.example.com/` For more information about website hosting in Amazon S3, see [Hosting websites on Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html) and [How to configure website page redirects](https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-page-redirect.html) in the *Amazon Simple Storage Service User Guide*. Type: String Default: None Constraints: The value must be prefixed by `/`, `http://`, or `https://`. The length of the value is limited to 2 KB.  |  No  | 

#### Additional Checksum Request Form Fields
<a name="post-object-additional-checksums"></a>

When uploading an object, you can specify various checksums that you would like to use to verify your data integrity. You can specify one additional checksum algorithm for Amazon S3 to use. For more information about additional checksum values, see [Checking object integrity](https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html) in the *Amazon Simple Storage Service User Guide*.


|  Name  |  Description  |  Required  | 
| --- | --- | --- | 
|  x-amz-checksum-algorithm  |  Indicates the algorithm used to create the checksum for the object. If a value is specified, you must include the matching checksum header. Otherwise, your request will generate a 400 error. Possible values include `CRC32`, `CRC32C`, `SHA1`, and `SHA256`.  | No | 
|  x-amz-checksum-crc32  |  Specifies the base64-encoded, 32-bit CRC32 checksum of the object. This parameter is required if the value of `x-amz-checksum-algorithm` is `CRC32`.  | Conditional | 
|  x-amz-checksum-crc32c  |  Specifies the base64-encoded, 32-bit CRC32C checksum of the object. This parameter is required if the value of `x-amz-checksum-algorithm` is `CRC32C`.  | Conditional | 
|  x-amz-checksum-sha1  |  Specifies the base64-encoded, 160-bit SHA-1 digest of the object. This parameter is required if the value of `x-amz-checksum-algorithm` is `SHA1`.  | Conditional | 
|  x-amz-checksum-sha256  |  Specifies the base64-encoded, 256-bit SHA-256 digest of the object. This parameter is required if the value of `x-amz-checksum-algorithm` is `SHA256`.  | Conditional | 

#### Server-Side Encryption Specific Request Form Fields
<a name="post-object-sse-specific-request-headers"></a>

Server-side encryption is data encryption at rest. Amazon S3 encrypts your data while writing it to disks in AWS data centers and decrypts your data when you access it. When uploading an object, you can specify the type of server-side encryption that you want Amazon S3 to use for encrypting the object. 

There are four types of server-side encryption: 
+ **Server-side encryption with Amazon S3 managed keys (SSE-S3)** – Starting May 2022, all Amazon S3 buckets have encryption configured by default. The default option for server-side encryption is with SSE-S3. Each object is encrypted with a unique key. As an additional safeguard, SSE-S3 encrypts the key itself with a root key that it regularly rotates. SSE-S3 uses one of the strongest block ciphers available, 256-bit Advanced Encryption Standard (AES-256), to encrypt your data.
+ **Server-side encryption with AWS KMS keys (SSE-KMS)** – SSE-KMS is provided through an integration of the AWS KMS service with Amazon S3. With AWS KMS, you have more control over your keys. For example, you can view separate keys, edit control policies, and follow the keys in AWS CloudTrail. Additionally, you can create and manage customer managed keys or use AWS managed keys that are unique to you, your service, and your Region.
+ **Dual-layer server-side encryption with AWS KMS keys (DSSE-KMS)** – Dual-layer server-side encryption with AWS KMS keys (DSSE-KMS) is similar to SSE-KMS, but applies two individual layers of object-level encryption instead of one layer. 
+ **Server-side encryption with customer-provided keys (SSE-C)** – With SSE-C, you manage the encryption keys, and Amazon S3 manages the encryption as it writes to disks, and the decryption when you access your objects. 
**Note**  
If you have server-side encryption with customer-provided keys (SSE-C) blocked for your general purpose bucket, you will get an HTTP 403 Access Denied error when you specify the SSE-C request headers while writing new data to your bucket. For more information, see [Blocking or unblocking SSE-C for a general purpose bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/blocking-unblocking-s3-c-encryption-gpb.html).

For more information, see [ Protecting data using server-side encryption](https://docs.aws.amazon.com/AmazonS3/latest/userguide/serv-side-encryption.html) in the *Amazon Simple Storage Service User Guide*.

Depending on which type of server-side encryption you want to use, specify the following form fields. 
+ **Use SSE-S3, SSE-KMS, or DSSE-KMS** – If you want to use these types of server-side encryption, specify the following form fields in the request.     
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html)
**Note**  
If you specify `x-amz-server-side-encryption:aws:kms` or `x-amz-server-side-encryption:aws:kms:dsse`, but do not provide `x-amz-server-side-encryption-aws-kms-key-id`, Amazon S3 uses the AWS managed key (`aws/S3`) to protect the data.
+ **Use SSE-C** – If you want to manage your own encryption keys, you must provide all the following form fields in the request. 
**Note**  
If you use SSE-C, the `ETag` value that Amazon S3 returns in the response is not the MD5 of the object.    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html)

### Responses
<a name="RESTObjectPOST-requests-responses"></a>

#### Response Headers
<a name="RESTObjectPOST-requests-responses-response-headers"></a>

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](RESTCommonResponseHeaders.md).


|  Name  |  Description  | 
| --- | --- | 
|  x-amz-checksum-crc32  |  The base64-encoded, 32-bit CRC32 checksum of the object. Type: String  | 
|  x-amz-checksum-crc32c  |  The base64-encoded, 32-bit CRC32C checksum of the object. Type: String  | 
|  x-amz-checksum-sha1  |  The base64-encoded, 160-bit SHA-1 digest of the object. Type: String  | 
|  x-amz-checksum-sha256  |  The base64-encoded, 256-bit SHA-256 digest of the object. Type: String  | 
|  x-amz-expiration  |  If an `Expiration` action is configured for the object as part of the bucket's lifecycle configuration, Amazon S3 returns this header.  The header value includes an `expiry-date` component and a URL-encoded `rule-id` component.  For version-enabled buckets, this header applies only to current versions. Amazon S3 does not provide a header to indicate when a noncurrent version is eligible for permanent deletion. For more information, see [PutBucketLifecycleConfiguration](API_PutBucketLifecycleConfiguration.md). Type: String  | 
|  success\$1action\$1redirect, redirect  |  The URL to which the client is redirected on a successful upload. Type: String Ancestor: PostResponse  | 
|  x-amz-server-side-encryption  |  The server-side encryption algorithm that was used when storing this object in Amazon S3 (for example, `AES256`, `aws:kms`, `aws:kms:dsse`). Type: String  | 
|  x-amz-server-side-encryption-aws-kms-key-id  |  If the `x-amz-server-side-encryption` header has a valid value of `aws:kms`, this header specifies the ID of the KMS key that was used to encrypt the object. Type: String  | 
|  x-amz-server-side-encryption-bucket-key-enabled  |  If `x-amz-server-side-encryption` has a valid value of `aws:kms`, this header indicates whether the object is encrypted with SSE-KMS by using an S3 Bucket Key. If this header is set to `true`, the object uses an S3 Bucket Key with SSE-KMS. Type: Boolean  | 
|  x-amz-server-side-encryption-customer-algorithm  |  If SSE-C was requested, the response includes this header, which confirms the encryption algorithm that was used. Type: String Valid Values: `AES256`  | 
|  x-amz-server-side-encryption-customer-key-MD5  |  If SSE-C was requested, the response includes this header to verify round-trip message integrity of the customer-provided encryption key. Type: String  | 
| x-amz-version-id |  Version of the object. Type: String  | 

#### Response Elements
<a name="RESTObjectPOST-requests-responses-response-elements"></a>


|  Name  |  Description  | 
| --- | --- | 
|  Bucket  |  The name of the bucket that the object was stored in. Type: String Ancestor: PostResponse  | 
|  ETag  |  The entity tag (ETag) is an MD5 hash of the object that you can use to do conditional `GET` operations by using the `If-Modified` request tag with the `GET` request operation. `ETag` reflects changes only to the contents of an object, not to its metadata. Type: String Ancestor: PostResponse  | 
|  Key  |  The object key name. Type: String Ancestor: PostResponse  | 
|  Location  |  The URI of the object. Type: String Ancestor: PostResponse  | 

#### Special Errors
<a name="RESTObjectPOST-requests-responses-special-errors"></a>

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](ErrorResponses.md).

## Examples
<a name="RESTObjectPOST-requests-examples"></a>

### Sample Request
<a name="ExampleVersionObjectPost"></a>

```
1. POST /Neo HTTP/1.1
2. Content-Length: 4
3. Host: quotes.s3.amazonaws.com
4. Date: Wed, 01 Mar  2006 12:00:00 GMT
5. Authorization: authorization string
6. Content-Type: text/plain
7. Expect: the 100-continue HTTP status code
8. 
9. ObjectContent
```

### Sample Response with Versioning Suspended
<a name="RESTObjectPOST-requests-examples-sample-response-with-versioning-suspended"></a>

The following is a sample response when bucket versioning is suspended:

```
 1. HTTP/1.1 100 Continue
 2. HTTP/1.1 200 OK
 3. x-amz-id-2: LriYPLdmOdAiIfgSm/F1YsViT1LW94/xUQxMsF7xiEb1a0wiIOIxl+zbwZ163pt7
 4. x-amz-request-id: 0A49CE4060975EAC
 5. x-amz-version-id: default
 6. Date: Wed, 12 Oct 2009 17:50:00 GMT
 7. ETag: "1b2cf535f27731c974343645a3985328"
 8. Content-Length: 0
 9. Connection: close
10. Server: AmazonS3
```

In this response, the version ID is `null`.

### Sample Response with Versioning Enabled
<a name="RESTObjectPOST-requests-examples-sample-response-with-versioning-enabled"></a>

The following is a sample response when bucket versioning is enabled.

```
 1. HTTP/1.1 100 Continue
 2. HTTP/1.1 200 OK
 3. x-amz-id-2: LriYPLdmOdAiIfgSm/F1YsViT1LW94/xUQxMsF7xiEb1a0wiIOIxl+zbwZ163pt7
 4. x-amz-request-id: 0A49CE4060975EAC
 5. x-amz-version-id: 43jfkodU8493jnFJD9fjj3HHNVfdsQUIFDNsidf038jfdsjGFDSIRp
 6. Date: Wed, 01 Mar  2006 12:00:00 GMT
 7. ETag: "828ef3fdfa96f00ad9f27c383fc9ac7f"
 8. Content-Length: 0
 9. Connection: close
10. Server: AmazonS3
```

## Related Resources
<a name="RESTObjectPOST-requests-related-resources"></a>
+  [CopyObject](API_CopyObject.md) 
+  [POST Object](#RESTObjectPOST) 
+  [GetObject](API_GetObject.md) 

# POST Object restore
<a name="RESTObjectPOSTrestore"></a>

## Description
<a name="RESTObjectPOSTrestore-description"></a>

This operation performs the following types of requests: 
+ `select` – Perform a select query on an archived object
+ `restore an archive` – Restore an archived object

To use this operation, you must have permissions to perform the `s3:RestoreObject` and `s3:GetObject` actions. The bucket owner has this permission by default and can grant this permission to others. For more information about permissions, see [Permissions Related to Bucket Subresource Operations](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources) and [Managing Access Permissions to Your Amazon S3 Resources](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html) in the *Amazon Simple Storage Service User Guide*.

## Querying Archives with Select Requests
<a name="RESTObjectPOSTrestore-select-request"></a>

You use a select type of request to perform SQL queries on archived objects. The archived objects that are being queried by the select request must be formatted as uncompressed comma-separated values (CSV) files. You can run queries and custom analytics on your archived data without having to restore your data to a hotter Amazon S3 tier. For an overview about select requests, see [Querying Archived Objects](https://docs.aws.amazon.com/AmazonS3/latest/userguide/querying-glacier-archives.html) in the *Amazon Simple Storage Service User Guide*.

When making a select request, do the following:
+ Define an output location for the select query's output. This must be an Amazon S3 bucket in the same AWS Region as the bucket that contains the archive object that is being queried. The AWS account that initiates the job must have permissions to write to the S3 bucket. You can specify the storage class and encryption for the output objects stored in the bucket. For more information about output, see [Querying Archived Objects](https://docs.aws.amazon.com/AmazonS3/latest/userguide/querying-glacier-archives.html) in the *Amazon Simple Storage Service User Guide*.

  For more information about the `S3` structure in the request body, see the following:
  + [PutObject](API_PutObject.md)
  + [Managing Access with ACLs](https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3_ACLs_UsingACLs.html) in the *Amazon Simple Storage Service User Guide*
  + [Protecting Data Using Server-Side Encryption](https://docs.aws.amazon.com/AmazonS3/latest/userguide/serv-side-encryption.html) in the *Amazon Simple Storage Service User Guide*
+ Define the SQL expression for the `SELECT` type of restoration for your query in the request body's `SelectParameters` structure. You can use expressions like the following examples.
  + The following expression returns all records from the specified object.

    ```
    SELECT * FROM Object
    ```
  + Assuming that you are not using any headers for data stored in the object, you can specify columns with positional headers.

    ```
    SELECT s._1, s._2 FROM Object s WHERE s._3 > 100
    ```
  + If you have headers and you set the `fileHeaderInfo` in the `CSV` structure in the request body to `USE`, you can specify headers in the query. (If you set the `fileHeaderInfo` field to `IGNORE`, the first row is skipped for the query.) You cannot mix ordinal positions with header column names. 

    ```
    SELECT s.Id, s.FirstName, s.SSN FROM S3Object s
    ```

For more information about using SQL with Amazon Glacier Select restore, see [SQL Reference for Amazon S3 Select and Amazon Glacier Select](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-glacier-select-sql-reference.html) in the *Amazon Simple Storage Service User Guide*. 

When making a select request, you can also do the following:
+ To expedite your queries, specify the `Expedited` tier. For more information about tiers, see "Restoring Archives," later in this topic.
+ Specify details about the data serialization format of both the input object that is being queried and the serialization of the CSV-encoded query results.

The following are additional important facts about the select feature:
+ The output results are new Amazon S3 objects. Unlike archive retrievals, they are stored until explicitly deleted—manually or through a lifecycle policy.
+ You can issue more than one select request on the same Amazon S3 object. Amazon S3 doesn't deduplicate requests, so avoid issuing duplicate requests.
+  Amazon S3 accepts a select request even if the object has already been restored. A select request doesn’t return error response `409`.

## Restoring Archives
<a name="RESTObjectPOSTrestore-restore-request"></a>

Objects in the GLACIER and DEEP\$1ARCHIVE storage classes are archived. To access an archived object, you must first initiate a restore request. This restores a temporary copy of the archived object. In a restore request, you specify the number of days that you want the restored copy to exist. After the specified period, Amazon S3 deletes the temporary copy but the object remains archived in the GLACIER or DEEP\$1ARCHIVE storage class that object was restored from. 

To restore a specific object version, you can provide a version ID. If you don't provide a version ID, Amazon S3 restores the current version.

The time it takes restore jobs to finish depends on which storage class the object is being restored from and which data access tier you specify. 

When restoring an archived object (or using a select request), you can specify one of the following data access tier options in the `Tier` element of the request body: 
+ **`Expedited`** - Expedited retrievals allow you to quickly access your data stored in the GLACIER storage class when occasional urgent requests for a subset of archives are required. For all but the largest archived objects (250 MB\$1), data accessed using Expedited retrievals are typically made available within 1–5 minutes. Provisioned capacity ensures that retrieval capacity for Expedited retrievals is available when you need it. Expedited retrievals and provisioned capacity are not available for the DEEP\$1ARCHIVE storage class.
+ **`Standard`** - Standard retrievals allow you to access any of your archived objects within several hours. This is the default option for the GLACIER and DEEP\$1ARCHIVE retrieval requests that do not specify the retrieval option. Standard retrievals typically complete within 3-5 hours from the GLACIER storage class and typically complete within 12 hours from the DEEP\$1ARCHIVE storage class. 
+ **`Bulk`** - Bulk retrievals are Amazon Glacier’s lowest-cost retrieval option, enabling you to retrieve large amounts, even petabytes, of data inexpensively in a day. Bulk retrievals typically complete within 5-12 hours from the GLACIER storage class and typically complete within 48 hours from the DEEP\$1ARCHIVE storage class.

For more information about archive retrieval options and provisioned capacity for `Expedited` data access, see [Restoring Archived Objects](https://docs.aws.amazon.com/AmazonS3/latest/userguide/restoring-objects.html) in the *Amazon Simple Storage Service User Guide*. 

You can use Amazon S3 restore speed upgrade to change the restore speed to a faster speed while it is in progress. You upgrade the speed of an in-progress restoration by issuing another restore request to the same object, setting a new `Tier` request element. When issuing a request to upgrade the restore tier, you must choose a tier that is faster than the tier that the in-progress restore is using. You must not change any other parameters, such as the `Days` request element. For more information, see [ Upgrading the Speed of an In-Progress Restore](https://docs.aws.amazon.com/AmazonS3/latest/userguide/restoring-objects.html#restoring-objects-upgrade-tier.title.html) in the *Amazon Simple Storage Service User Guide*. 

To get the status of object restoration, you can send a `HEAD` request. Operations return the `x-amz-restore` header, which provides information about the restoration status, in the response. You can use Amazon S3 event notifications to notify you when a restore is initiated or completed. For more information, see [Configuring Amazon S3 Event Notifications](https://docs.aws.amazon.com/AmazonS3/latest/userguide/NotificationHowTo.html) in the *Amazon Simple Storage Service User Guide*.

After restoring an archived object, you can update the restoration period by reissuing the request with a new period. Amazon S3 updates the restoration period relative to the current time and charges only for the request—there are no data transfer charges.   You cannot update the restoration period when Amazon S3 is actively processing your current restore request for the object.

If your bucket has a lifecycle configuration with a rule that includes an expiration action, the object expiration overrides the life span that you specify in a restore request. For example, if you restore an object copy for 10 days, but the object is scheduled to expire in 3 days, Amazon S3 deletes the object in 3 days. For more information about lifecycle configuration, see [PutBucketLifecycleConfiguration](API_PutBucketLifecycleConfiguration.md) and [Object Lifecycle Management](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html) in *Amazon Simple Storage Service User Guide*.

## Requests
<a name="RESTObjectPOSTrestore-requests"></a>

### Syntax
<a name="RESTObjectPOSTrestore-requests-syntax"></a>

```
1. POST /ObjectName?restore&versionId=VersionID HTTP/1.1
2. Host: BucketName.s3.amazonaws.com
3. Date: date
4. Authorization: authorization string (see Authenticating Requests (AWS Signature Version 4))
5. Content-MD5: MD5
6. 
7.  request body
```

**Note**  
The syntax shows some of the request headers. For a complete list, see "Request Headers," later in this topic.

### Request Parameters
<a name="RESTObjectPOSTrestore-requests-request-parameters"></a>

This implementation of the operation does not use request parameters.

### Request Headers
<a name="RESTObjectPOSTrestore-requests-request-headers"></a>


|  Name  |  Description  |  Required  | 
| --- | --- | --- | 
| Content-MD5 |  The base64-encoded 128-bit MD5 digest of the data. You must use this header as a message integrity check to verify that the request body was not corrupted in transit. For more information, see [RFC 1864](http://www.ietf.org/rfc/rfc1864.txt). Type: String  Default: None  | Yes  | 

### Request Elements
<a name="RESTObjectPOSTrestore-requests-request-elements"></a>

The following is an XML example of a request body for restoring an archive. 

```
<RestoreRequest>
   <Days>2</Days> 
   <GlacierJobParameters>
     <Tier>Bulk</Tier>
   </GlacierJobParameters> 
</RestoreRequest>
```

The following table explains the XML for archive restoration in the request body. 


|  Name  |  Description  |  Required  | 
| --- | --- | --- | 
| RestoreRequest |  Container for restore information. Type: Container  | Yes | 
| Days |  Lifetime of the restored (active) copy. The minimum number of days that you can restore an object from Amazon Glacier is 1. After the object copy reaches the specified lifetime, Amazon S3 removes it from the bucket. If you are restoring an archive, this element is required.  Do not use this element with a `SELECT` type of request. Type: Positive integer Ancestors: `RestoreRequest`  | Yes, if restoring an archive | 
| GlacierJobParameters |  Container for Glacier job parameters. Do not use this element with a `SELECT` type of request. Type: Container Ancestors: `RestoreRequest`  | No | 
| Tier |  The data access tier to use when restoring the archive. `Standard` is the default. Type: Enum Valid values: `Expedited` \$1 `Standard` \$1 `Bulk` Ancestors: `GlacierJobParameters`  | No | 

The following XML is the request body for a select query on an archived object: 

```
<RestoreRequest>
    <Type>SELECT</Type>
    <Tier>Expedited</Tier>
    <Description>Job description</Description>
    <SelectParameters>
          <Expression>Select * from Object</Expression>
          <ExpressionType>SQL</ExpressionType>
          <InputSerialization>
              <CSV>
                  <FileHeaderInfo>IGNORE</FileHeaderInfo>
                  <RecordDelimiter>\n</RecordDelimiter>
                  <FieldDelimiter>,</FieldDelimiter>
                  <QuoteCharacter>"</QuoteCharacter>
                  <QuoteEscapeCharacter>"</QuoteEscapeCharacter>
                  <Comments>#</Comments>
              </CSV>
           </InputSerialization>
         <OutputSerialization>
             <CSV>
                 <QuoteFields>ASNEEDED</QuoteFields>
                 <RecordDelimiter>\n</RecordDelimiter>
                 <FieldDelimiter>,</FieldDelimiter>
                 <QuoteCharacter>"</QuoteCharacter>
                 <QuoteEscapeCharacter>"</QuoteEscapeCharacter>
             </CSV>                                
         </OutputSerialization>
    </SelectParameters>
    <OutputLocation>
        <S3>
	     <BucketName>Name of bucket</BucketName>
            <Prefix>Key prefix</Prefix>
	      <CannedACL>Canned ACL string</CannedACL>
	      <AccessControlList>
		    <Grantee>
		        <Type>Grantee Type</Type>
			 <ID>Grantee identifier</ID>
			 <URI>Grantee URI</URI>
		       <Permission>Granted permission</Permission>
                    <DisplayNmae>Display Name</DisplayName>
                    <EmailAddress>email</EmailAddress>
		    </Grantee>
	      </AccessControlList>
	      <Encryption>
	            <EncryptionType>Encryption type</EncryptionType>
		     <KMSKeyId>KMS Key ID</KMSKeyId>
		     <KMSContext>Base64-encoded JSON<KMSContext>
            </Encryption>
	     <UserMetadata>
               <MetadataEntry>
                   <Name>Key</Name>
                   <Value>Value</Value>
               </MetadataEntry>
            </UserMetadata>
            <Tagging>
                <TagSet>
                    <Tag>
                        <Key>Tag name</Key>
                        <Value>Tag value</Value>
                    </Tag>
               </TagSet>
            </Tagging>
            <StorageClass>Storage class</StorageClass>
	 </S3>
    </OutputLocation>
</RestoreRequest>
```

The following tables explain the XML for a `SELECT` type of restoration in the request body. 


|  Name  |  Description  |  Required  | 
| --- | --- | --- | 
| RestoreRequest |  Container for restore information. Type: Container  | Yes | 
| Tier |  The data access tier to use when restoring the archive. `Standard` is the default. Type: Enum Valid values: `Expedited` \$1 `Standard` \$1 `Bulk` Ancestors: `RestoreRequest`  | No | 
| Description |  The optional description for the request. Type: String Ancestors: `RestoreRequest`  | No | 
| SelectParameters |  Describes the parameters for the select job request. Type: Container Ancestors: `RestoreRequest`  | Yes, if request type is SELECT  | 
| OutputLocation |  Describes the location that receives the results of the select restore request. Type: Container for Amazon S3 Ancestors: `RestoreRequest`  | Yes, if request type is SELECT  | 


**The `SelectParameters` container element contains the following elements.**  

|  Name  |  Description  |  Required  | 
| --- | --- | --- | 
| Expression |  The SQL expression. For example: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOSTrestore.html) Type: String Ancestors: `SelectParameters`  | Yes | 
| ExpressionType |  Identifies the expression type. Type: String Valid values: `SQL` Ancestors: `SelectParameters`  | Yes | 
| InputSerialization |  Describes the serialization format of the object. Type: Container for CSV Ancestors: `SelectParameters`  | Yes | 
| OutputSerialization |  Describes how the results of the select job are serialized. Type: Container for CSV Ancestors: `SelectParameters`  | Yes | 


**The CSV container element in the `InputSerialization` element contains the following elements.**  

|  Name  |  Description  |  Required  | 
| --- | --- | --- | 
| RecordDelimiter |  A single character used to separate individual records in the input. Instead of the default value, you can specify an arbitrary delimiter. Type: String Default: `\n` Ancestors: `CSV`  | No | 
| FieldDelimiter |  A single character used to separate individual fields in a record. You can specify an arbitrary delimiter.  Type: String Default: `,` Ancestors: `CSV`  | No | 
| QuoteCharacter |  A single character used for escaping when the field delimiter is part of the value. Consider this example in a CSV file:  `"a, b" ` Wrapping the value in quotation marks makes this value a single field. If you don't use the quotation marks, the comma is a field delimiter (which makes it two separate field values, a and b). Type: String Default: `"` Ancestors: `CSV`  | No | 
| QuoteEscapeCharacter |  A single character used for escaping the quotation mark character inside an already escaped value. For example, the value `""" a , b """` is parsed as `" a , b "`. Type: String Default: `"` Ancestors: `CSV`  | No | 
| FileHeaderInfo |  Describes the first line in the input data. It is one of the ENUM values. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOSTrestore.html) Type: Enum Valid values: `NONE \| USE \| IGNORE` Ancestors: `CSV`  | No | 
| Comments |  A single character used to indicate that a row should be ignored when the character is present at the start of that row. You can specify any character to indicate a comment line. Type: String Ancestors: `CSV`  | No | 


**The CSV container element (in the `OutputSerialization` elements) contains the following elements.**  

|  Name  |  Description  |  Required  | 
| --- | --- | --- | 
| QuoteFields |  Indicates whether to use quotation marks around output fields.  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOSTrestore.html) Type: Enum Valid values: `ALWAYS \| ASNEEDED` Default: `AsNeeded` Ancestors: `CSV`  | No | 
| RecordDelimiter |  A single character used to separate individual records in the output. Instead of the default value, you can specify an arbitrary delimiter.  Type: String Default: `\n` Ancestors: `CSV`  | No | 
| FieldDelimiter |  A single character used to separate individual fields in a record. You can specify an arbitrary delimiter.  Type: String Default: `,` Ancestors: `CSV`  | No | 
| QuoteCharacter |  A single character used for escaping when the field delimiter is part of the value. For example, if the value is `a, b`, Amazon S3 wraps this field value in quotation marks, as follows: `" a , b "`. Type: String Default: `"` Ancestors: `CSV`  | No | 
| QuoteEscapeCharacter |  A single character used for escaping the quotation mark character inside an already escaped value. For example, if the value is `" a , b "`, Amazon S3 wraps the value in quotation marks, as follows: `""" a , b """`. Type: String Ancestors: `CSV`  | No | 


**The S3 container element (in the `OutputLocation` element) contains the following elements.**  

|  Name  |  Description  |  Required  | 
| --- | --- | --- | 
| AccessControlList |  A list of grants that control access to the staged results.  Type: Container for Grant Ancestors: `S3`  | No | 
| BucketName |  The name of the S3 bucket where the select restore results are stored. The bucket must be in the same AWS Region as the bucket that contains the input archive object. Type: String Ancestors: `S3`  | Yes | 
| CannedACL |  The canned access control list (ACL) to apply to the select restore results. Type: String Valid values: ` private \| public-read \| public-read-write \| aws-exec-read \| authenticated-read \| bucket-owner-read \| bucket-owner-full-control` Ancestors: `S3`  | No | 
| Encryption |  Contains encryption information for the stored results. Type: Container for Encryption Ancestors: `S3`  | No | 
| Prefix |  The prefix that is prepended to the select restore results. The maximum length for the prefix is 512 bytes. Type: String Ancestors: `S3`  | Yes | 
| StorageClass |  The class of storage used to store the select request results. Type: String Valid values: `STANDARD` \$1 `REDUCED_REDUNDANCY` \$1 `STANDARD_IA` \$1 `ONEZONE_IA`  Ancestors: `S3 `  | No | 
| Tagging |  Container for tag information. Type: Tag structure Ancestors: `S3 `  | No | 
| UserMetadata |  Contains a list of metadata to store with the select restore results. Type: MetadataEntry structure Ancestors: `S3`  | No | 


**The Grantee container element (in the `AccessControlList` element) contains the following elements.**  

|  Name  |  Description  |  Required  | 
| --- | --- | --- | 
| DisplayName |  The screen name of the grantee. Type: String Ancestors: `Grantee`  | No | 
| EmailAddress |  The email address of the grantee. Type: String Ancestors: `Grantee`  | No | 
| ID |  The canonical user ID of the grantee. Type: String Ancestors: `Grantee`  | No | 
| Type |  The type of the grantee. Type: String Ancestors: `Grantee`  | No | 
| URI |  The URI of the grantee group. Type: String Ancestors: `Grantee`  | No | 
| Permission |  Granted permission. Type: String Ancestors: `Grantee`  | No | 


**The `Encryption` container element (in S3) contains the following elements.**  

|  Name  |  Description  |  Required  | 
| --- | --- | --- | 
| EncryptionType |  The server-side encryption algorithm used when storing job results. The default is no encryption. Type: String Valid Values `aws:kms \| AES256` Ancestors: `Encryption`   | No | 
| KMSContext |  Optional. If the encryption type is `aws:kms`, you can use this value to specify the encryption context for the select restore results. Type: String Ancestors: Encryption   | No | 
| KMSKeyId |  The AWS Key Management Service (AWS KMS) key ID to use for object encryption. Type: String Ancestors: `Encryption`   | No | 


**The `TagSet` container element (in the `Tagging` element) contains the following element.**  

|  Name  |  Description  |  Required  | 
| --- | --- | --- | 
| Tag |  Contains tags. Type: Container Ancestors: `TagSet`   | No | 


**The Tag container element (in the `TagSet` element) contains the following elements.**  

|  Name  |  Description  |  Required  | 
| --- | --- | --- | 
| Key |  Name of the tag.  Type: String Ancestors: `Tag`  | No | 
| Value |  Value of the tag. Type: String Ancestors: `Tag`  | No | 


**The `MetadataEntry` container element (in the `UserMetadata` element) contains the following key-value pair elements to store with an object.**  

|  Name  |  Description  |  Required  | 
| --- | --- | --- | 
| MetadataKey |  The metadata key. Type: String Ancestors: ``  | No | 
| MetadataEntry |  The metadata value. Type: String Ancestors: ``  | No | 

## Responses
<a name="RESTObjectPOSTrestore-responses"></a>

A successful operation returns either the `200 OK` or `202 Accepted` status code. 
+ If the object copy is not previously restored, then Amazon S3 returns `202 Accepted` in the response. 
+ If the object copy is previously restored, Amazon S3 returns `200 OK` in the response. 

### Response Headers
<a name="RESTObjectPOSTrestore-responses-response-headers"></a>

This implementation of the operation uses only response headers that are common to most responses. For more information, see [Common Response Headers](RESTCommonResponseHeaders.md).

### Response Elements
<a name="RESTObjectPOSTrestore-responses-response-elements"></a>

This operation does not return response elements.

### Special Errors
<a name="RESTObjectPOSTrestore-responses-special-errors"></a>


| Error Code | Description | HTTP Status Code | SOAP Fault Code Prefix | 
| --- | --- | --- | --- | 
| RestoreAlreadyInProgress | Object restore is already in progress. (This error does not apply to SELECT type requests.) | 409 Conflict | Client | 
| GlacierExpeditedRetrievalNotAvailable | Glacier expedited retrievals are currently not available. Try again later. (Returned if there is insufficient capacity to process the Expedited request. This error applies only to Expedited retrievals and not to Standard or Bulk retrievals.) | 503 | N/A | 

## Examples
<a name="RESTObjectPOSTrestore-responses-examples"></a>

### Restore an Object for Two Days Using the Expedited Retrieval Option
<a name="RESTObjectPOSTrestore-responses-examples-sample-request"></a>

The following restore request restores a copy of the `photo1.jpg` object from Amazon Glacier for a period of two days using the expedited retrieval option.

```
 1. POST /photo1.jpg?restore HTTP/1.1
 2. Host: examplebucket.s3.amazonaws.com
 3. Date: Mon, 22 Oct 2012 01:49:52 GMT
 4. Authorization: authorization string
 5. Content-Length: content length
 6. 
 7. <RestoreRequest>
 8.   <Days>2</Days>
 9.   <GlacierJobParameters>
10.     <Tier>Expedited</Tier>
11.   </GlacierJobParameters>
12. </RestoreRequest>
```

If the `examplebucket` does not have a restored copy of the object, Amazon S3 returns the following `202 Accepted` response. 

```
HTTP/1.1 202 Accepted
x-amz-id-2: GFihv3y6+kE7KG11GEkQhU7/2/cHR3Yb2fCb2S04nxI423Dqwg2XiQ0B/UZlzYQvPiBlZNRcovw=
x-amz-request-id: 9F341CD3C4BA79E0
Date: Sat, 20 Oct 2012 23:54:05 GMT
Content-Length: 0
Server: AmazonS3
```

If a copy of the object is already restored, Amazon S3 returns a `200 OK` response, and updates only the restored copy's expiry time.

### Query an Archive with a SELECT Request
<a name="RESTObjectPOSTrestore-responses-examples-select-request"></a>

The following is an example select restore request.

```
 1. POST /object-one.csv?restore HTTP/1.1
 2. Host: examplebucket.s3.amazonaws.com
 3. Date: Date: Sat, 20 Oct 2012 23:54:05 GMT
 4. Authorization: authorization string
 5. Content-Length: content length
 6. 
 7. <RestoreRequest xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
 8.   <Type>SELECT</Type>
 9.   <Tier>Expedited</Tier>
10.   <Description>this is a description</Description>
11.   <SelectParameters>
12.     <InputSerialization>
13.       <CSV>
14.         <FileHeaderInfo>IGNORE</FileHeaderInfo>
15.         <Comments>#</Comments>
16.         <QuoteEscapeCharacter>"</QuoteEscapeCharacter>
17.         <RecordDelimiter>\n</RecordDelimiter>
18.         <FieldDelimiter>,</FieldDelimiter>
19.         <QuoteCharacter>"</QuoteCharacter>
20.       </CSV>
21.     </InputSerialization>
22.     <ExpressionType>SQL</ExpressionType>
23.     <Expression>select * from object</Expression>
24.     <OutputSerialization>
25.       <CSV>
26.         <QuoteFields>ALWAYS</QuoteFields>
27.         <QuoteEscapeCharacter>"</QuoteEscapeCharacter>
28.         <RecordDelimiter>\n</RecordDelimiter>
29.         <FieldDelimiter>\t</FieldDelimiter>
30.         <QuoteCharacter>\'</QuoteCharacter>
31.       </CSV>
32.     </OutputSerialization>
33.   </SelectParameters>
34.   <OutputLocation>
35.     <S3>
36.       <BucketName>example-output-bucket</BucketName>
37.       <Prefix>test-s3</Prefix>
38.       <AccessControlList>
39.         <Grant>
40.           <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AmazonCustomerByEmail">
41.             <EmailAddress>jane-doe@example.com</EmailAddress>
42.           </Grantee>
43.           <Permission>FULL_CONTROL</Permission>
44.         </Grant>
45.       </AccessControlList>
46.       <UserMetadata>
47.         <MetadataEntry>
48.           <Name>test</Name>
49.           <Value>test-value</Value>
50.         </MetadataEntry>
51.         <MetadataEntry>
52.           <Name>other</Name>
53.           <Value>something else</Value>
54.         </MetadataEntry>
55.       </UserMetadata>
56.       <StorageClass>STANDARD</StorageClass>
57.     </S3>
58.   </OutputLocation>
59. </RestoreRequest>
```

 Amazon S3 returns the following `202 Accepted` response. 

```
1. HTTP/1.1 202 Accepted
2. x-amz-id-2: GFihv3y6+kE7KG11GEkQhU7/2/cHR3Yb2fCb2S04nxI423Dqwg2XiQ0B/UZlzYQvPiBlZNRcovw=
3. x-amz-request-id: 9F341CD3C4BA79E0
4. x-amz-restore-output-path: js-test-s3/qE8nk5M0XIj-LuZE2HXNw6empQm3znLkHlMWInRYPS-Orl2W0uj6LyYm-neTvm1-btz3wbBxfMhPykd3jkl-lvZE7w42/
5. Date: Sat, 20 Oct 2012 23:54:05 GMT
6. Content-Length: 0
7. Server: AmazonS3
```

## More Info
<a name="RESTObjectPOSTrestore-responses-related-resources-post-res"></a>
+  [GetBucketLifecycleConfiguration](API_GetBucketLifecycleConfiguration.md) 
+ [PutBucketLifecycleConfiguration](API_PutBucketLifecycleConfiguration.md)
+ [SQL Reference for Amazon S3 Select and Amazon Glacier Select ](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-glacier-select-sql-reference.html) in the *Amazon Simple Storage Service User Guide* 

## Browser-Based Uploads Using HTTP POST
<a name="sigv4-UsingHTTPPOST-how-to"></a>

Amazon S3 supports HTTP POST requests so that users can upload content directly to Amazon S3. By using POST, end users can authenticate requests without having to pass data through a secure intermediary node that protects your credentials. Thus, HTTP POST has the potential to reduce latency.

The following figure shows an Amazon S3 upload using a POST request.

![\[Comparison of S3 PUT and POST methods for file transfer from customer to Amazon S3.\]](http://docs.aws.amazon.com/AmazonS3/latest/API/images/s3_post.png)


1.  The user accesses your page from a web browser. 

1.  Your webpage contains an HTML form that contains all the information necessary for the user to upload content to Amazon S3. 

1.  The user uploads content to Amazon S3 through the web browser. 

The process for sending browser-based POST requests is as follows:

 

1. Create a security policy specifying conditions that restrict what you want to allow in the request, such as the bucket name where objects can be uploaded, and key name prefixes that you want to allow for the object that is being created.

1. Create a signature that is based on the policy. For authenticated requests, the form must include a valid signature and the policy.

1. Create an HTML form that your users can access in order to upload objects to your Amazon S3 bucket.

The following section describes how to create a signature to authenticate a request. For information about creating forms and security policies, see [Creating an HTML Form (Using AWS Signature Version 4)](sigv4-HTTPPOSTForms.md).

## Calculating a Signature
<a name="sigv4-post-signature-calc"></a>

For authenticated requests, the HTML form must include fields for a security policy and a signature. 

 
+ A security policy (see [POST Policy](sigv4-HTTPPOSTConstructPolicy.md)) controls what is allowed in the request.
+ The security policy is the `StringToSign` (see [Introduction to Signing Requests](sig-v4-authenticating-requests.md#signing-request-intro)) in your signature calculation.

 

![\[StringToSign, Signing Key, and Signature\]](http://docs.aws.amazon.com/AmazonS3/latest/API/images/sigV4-post.png)






**To Calculate a signature**

1. Create a policy using UTF-8 encoding.

1. Convert the UTF-8-encoded policy bytes to base64. The result is the `StringToSign`.

1. Create a signing key.

1. Use the signing key to sign the `StringToSign` using HMAC-SHA256 signing algorithm.

For more information about creating HTML forms, security policies, and an example, see the following:


+ [Creating an HTML Form (Using AWS Signature Version 4)](sigv4-HTTPPOSTForms.md)
+ [POST Policy](sigv4-HTTPPOSTConstructPolicy.md)
+ [Example: Browser-Based Upload using HTTP POST (Using AWS Signature Version 4)](sigv4-post-example.md)



# Creating an HTML Form (Using AWS Signature Version 4)
<a name="sigv4-HTTPPOSTForms"></a>

**Topics**
+ [

## HTML Form Declaration
](#HTTPPOSTFormDeclaration)
+ [

## HTML Form Fields
](#sigv4-HTTPPOSTFormFields)

To allow users to upload content to Amazon S3 by using their browsers (HTTP POST requests), you use HTML forms. HTML forms consist of a form declaration and form fields. The form declaration contains high-level information about the request. The form fields contain detailed request information.

This section describes how to create HTML forms. For a working example of browser-based upload using HTTP POST and related signature calculations for request authentication, see [Example: Browser-Based Upload using HTTP POST (Using AWS Signature Version 4)](sigv4-post-example.md).

The form and policy must be UTF-8 encoded. You can apply UTF-8 encoding to the form by specifying `charset=UTF-8` in the `content` attribute. The following is an example of UTF-8 encoding in the HTML heading.

```
1. <html>
2.   <head>
3.     ...
4.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5.     ...
6.   </head>
7.   <body>
```

Following is an example of UTF-8 encoding in a request header.

```
1. Content-Type: text/html; charset=UTF-8
```

**Note**  
The form data and boundaries (excluding the contents of the file) cannot exceed 20KB.

## HTML Form Declaration
<a name="HTTPPOSTFormDeclaration"></a>

The HTML form declaration has the following three attributes:

 
+ `action` – The URL that processes the request, which must be set to the URL of the bucket. For example, if the name of your bucket is `examplebucket`, the URL is `http://examplebucket.s3.amazonaws.com/`.
**Note**  
The key name is specified in a form field.
+  `method` – The method must be POST.
+  `enctype` – The enclosure type (`enctype`) must be set to multipart/form-data for both file uploads and text area uploads. For more information about `enctype`, see [RFC 1867](http://www.ietf.org/rfc/rfc1867.txt).

This is a form declaration for the bucket `examplebucket`.

```
1. <form action="http://examplebucket.s3.amazonaws.com/" method="post"
2. 
3. enctype="multipart/form-data">
```

## HTML Form Fields
<a name="sigv4-HTTPPOSTFormFields"></a>

The following table describes a list of fields that you can use within a form. Among other fields, there is a signature field that you can use to authenticate requests. There are fields for you to specify the signature calculation algorithm (`x-amz-algorithm`), the credential scope (`x-amz-credential`) that you used to generate the signing key, and the date (`x-amz-date`) used to calculate the signature. Amazon S3 uses this information to re-create the signature. If the signatures match, Amazon S3 processes the request.

**Note**  
The variable `${filename}` is automatically replaced with the name of the file provided by the user and is recognized by all form fields. If the browser or client provides a full or partial path to the file, only the text following the last slash (/) or backslash (\$1) is used (for example, `C:\Program Files\directory1\file.txt` is interpreted as `file.txt`). If no file or file name is provided, the variable is replaced with an empty string.

If you don't provide elements required for authenticated requests, such as the `policy` element, the request is assumed to be anonymous and will succeed only if you have configured the bucket for public read and write. 


| Element Name | Description | Required | 
| --- | --- | --- | 
| acl |  An Amazon S3 access control list (ACL). If an invalid ACL is specified, Amazon S3 denies the request. For more information about ACLs, see [Using Amazon S3 ACLs](https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3_ACLs_UsingACLs.html). Type: String Default: private  Valid Values: `private \| public-read \| public-read-write \| aws-exec-read \| authenticated-read \| bucket-owner-read \| bucket-owner-full-control `   |  No  | 
| Cache-Control `Content-Type` `Content-Disposition` `Content-Encoding` `Expires` |  REST-specific headers. For more information, see [PutObject](API_PutObject.md).  |  No  | 
| key |  The key name of the uploaded object. To use the file name provided by the user, use the \$1\$1filename\$1 variable. For example, if you upload a file `photo1.jpg` and you specify `/user/user1/${filename}` as key name, the file is stored as `/user/user1/photo1.jpg`. For more information, see [Object Key and Metadata](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html) in the *Amazon Simple Storage Service User Guide*.  |  Yes  | 
| policy |  The base64-encoded security policy that describes what is permitted in the request. For authenticated requests, a policy is required.  Requests without a security policy are considered anonymous and will succeed only on a publicly writable bucket.   |  Required for authenticated requests  | 
| success\$1action\$1redirect |  The URL to which the client is redirected upon successful upload. If `success_action_redirect` is not specified, or Amazon S3 cannot interpret the URL, Amazon S3 returns the empty document type that is specified in the `success_action_status` field. If the upload fails, Amazon S3 returns an error and does not redirect the user to another URL.   |  No  | 
| success\$1action\$1status |  The status code returned to the client upon successful upload if `success_action_redirect` is not specified. Valid values are `200`, `201`, or `204` (default). If the value is set to 200 or 204, Amazon S3 returns an empty document with the specified status code. If the value is set to 201, Amazon S3 returns an XML document with a 201 status code. For information about the content of the XML document, see [POST Object](RESTObjectPOST.md). If the value is not set or is invalid, Amazon S3 returns an empty document with a 204 status code.   Some versions of the Adobe Flash player do not properly handle HTTP responses with an empty body. To support uploads through Adobe Flash, we recommend setting `success_action_status` to 201.   |  No  | 
| x-amz-algorithm |  The signing algorithm used to authenticate the request. For AWS Signature Version 4, the value is `AWS4-HMAC-SHA256`.  This field is required if a policy document is included with the request.  |  Required for authenticated requests  | 
| x-amz-credential |  In addition to your access key ID, this field also provides scope information identifying region and service for which the signature is valid. This should be the same scope you used in calculating the signing key for signature calculation. It is a string of the following form:`<your-access-key-id>/<date>/<aws-region>/<aws-service>/aws4_request `For example: ` AKIAIOSFODNN7EXAMPLE/20130728/us-east-1/s3/aws4_request` ` `  For Amazon S3, the aws-service string is s3. For a list of Amazon S3 aws-region strings, see [Regions and Endpoints](https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region) in the AWS General Reference. This is required if a policy document is included with the request. |  Required for authenticated requests  | 
| x-amz-date |  It is the date value in ISO8601 format. For example, `20130728T000000Z`.  It is the same date you used in creating the signing key (for example, 20130728). This must also be the same value you provide in the policy (`x-amz-date`) that you signed.  This is required if a policy document is included with the request.  |  Required for authenticated requests  | 
| x-amz-security-token |  A security token used by Amazon DevPay and session credentials  If the request is using Amazon DevPay, it requires two `x-amz-security-token` form fields: one for the product token and one for the user token. For more information, see [Using DevPay](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingDevPay.html) in the *Amazon Simple Storage Service User Guide*. If the request is using session credentials, it requires one `x-amz-security-token` form. For more information, see [Requesting Temporary Security Credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html) in the *IAM User Guide*.  |  No  | 
| x-amz-signature |  (AWS Signature Version 4) The HMAC-SHA256 hash of the security policy.   This field is required if a policy document is included with the request.  |  Required for authenticated requests  | 
| x-amz-meta-\$1 |  Field names starting with this prefix are user-defined metadata. Each one is stored and returned as a set of key-value pairs. Amazon S3 doesn't validate or interpret user-defined metadata. For more information, see [PutObject](API_PutObject.md).  |  No  | 
| x-amz-\$1 |  See POST Object ([POST Object](RESTObjectPOST.md) for other `x-amz-*` headers.  |  No  | 
| file |  File or text content.  The file or content must be the last field in the form. You cannot upload more than one file at a time.  |  Yes  | 

Conditional items are required for authenticated requests and are optional for anonymous requests. 

Now that you know how to create forms, next you can create a security policy that you can sign. For more information, see [POST Policy](sigv4-HTTPPOSTConstructPolicy.md).

# POST Policy
<a name="sigv4-HTTPPOSTConstructPolicy"></a>

**Topics**
+ [

## Expiration
](#sigv4-HTTPPOSTExpiration)
+ [

## Condition Matching
](#sigv4-ConditionMatching)
+ [

## Conditions
](#sigv4-PolicyConditions)
+ [

## Character Escaping
](#sigv4-HTTPPOSTEscaping)

The policy required for making authenticated requests using HTTP POST is a UTF-8 and base64-encoded document written in JavaScript Object Notation (JSON) that specifies conditions that the request must meet. Depending on how you design your policy document, you can control the access granularity per-upload, per-user, for all uploads, or according to other designs that meet your needs.

This section describes the POST policy. For example signature calculations using POST policy, see [Example: Browser-Based Upload using HTTP POST (Using AWS Signature Version 4)](sigv4-post-example.md).

**Note**  
Although the policy document is optional, we highly recommend that you use one in order to control what is allowed in the request. If you make the bucket publicly writable, you have no control at all over which users can write to your bucket.  
 

The following is an example of a POST policy document.

```
1. { "expiration": "2007-12-01T12:00:00.000Z",
2.   "conditions": [
3.     {"acl": "public-read" },
4.     {"bucket": "johnsmith" },
5.     ["starts-with", "$key", "user/eric/"],
6.   ]
7. }
```

The POST policy always contains the `expiration` and `conditions` elements. The example policy uses two condition matching types (exact matching and starts-with matching). The following sections describe these elements.

## Expiration
<a name="sigv4-HTTPPOSTExpiration"></a>

The `expiration` element specifies the expiration date and time of the POST policy in ISO8601 GMT date format. For example, `2013-08-01T12:00:00.000Z` specifies that the POST policy is not valid after midnight GMT on August 1, 2013.

## Condition Matching
<a name="sigv4-ConditionMatching"></a>

Following is a table that describes condition matching types that you can use to specify POST policy conditions (described in the next section). Although you must specify at least one condition for each form field that you specify in the form, you can create more complex matching criteria by specifying multiple conditions for a form field.


|  Condition Match Type |  Description  | 
| --- | --- | 
|  Exact Matches  |  The form field value must match the value specified. This example indicates that the ACL must be set to public-read: <pre>{"acl": "public-read" }</pre> This example is an alternate way to indicate that the ACL must be set to public-read: <pre>[ "eq", "$acl", "public-read" ]</pre>  | 
|  Starts With  |  The value must start with the specified value. This example indicates that the object key must start with user/user1: <pre>["starts-with", "$key", "user/user1/"]</pre>  | 
|  Matching Content-Types in a Comma-Separated List  |  Content-Types values for a `starts-with` condition that include commas are interpreted as lists. Each value in the list must meet the condition for the whole condition to pass. For example,given the following condition: <pre>["starts-with", "$Content-Type", "image/"]</pre> The following value would pass the condition: <pre>"image/jpg,image/png,image/gif"</pre> The following value would not pass the condition: <pre>["image/jpg,text/plain"]</pre> Data elements other than `Content-Type` are treated as strings, regardless of the presence of commas.  | 
|  Matching Any Content  |  To configure the POST policy to allow any content within a form field, use `starts-with` with an empty value (""). This example allows any value for `success_action_redirect`: <pre>["starts-with", "$success_action_redirect", ""]</pre>  | 
|  Specifying Ranges  |  For form fields that accept a range, separate the upper and lower limit with a comma. This example allows a file size from 1 to 10 MiB: <pre>["content-length-range", 1048576, 10485760]</pre>  | 

The specific conditions supported in a POST policy are described in [Conditions](#sigv4-PolicyConditions).

## Conditions
<a name="sigv4-PolicyConditions"></a>

The `conditions` in a POST policy is an array of objects, each of which is used to validate the request. You can use these conditions to restrict what is allowed in the request. For example, the preceding policy conditions require the following:

 
+ Request must specify the `johnsmith` bucket name.
+ Object key name must have the `user/eric` prefix.
+ Object ACL must be set to `public-read`.

Each form field that you specify in a form (except `x-amz-signature`, `file`, `policy`, and field names that have an `x-ignore-` prefix) must appear in the list of conditions. 

**Note**  
 All variables within the form are expanded prior to validating the POST policy. Therefore, all condition matching should be against the expanded form fields. Suppose that you want to restrict your object key name to a specific prefix (`user/user1`). In this case, you set the key form field to `user/user1/${filename}`. Your POST policy should be `[ "starts-with", "$key", "user/user1/" ]` (do not enter `[ "starts-with", "$key", "user/user1/${filename}" ]`). For more information, see [Condition Matching](#sigv4-ConditionMatching). 

Policy document conditions are described in the following table.


| Element Name | Description | 
| --- | --- | 
| acl |  Specifies the ACL value that must be used in the form submission.  This condition supports exact matching and `starts-with` condition match type discussed in the following section.  | 
| bucket |  Specifies the acceptable bucket name.  This condition supports exact matching condition match type.  | 
| content-length-range |  The minimum and maximum allowable size for the uploaded content.  This condition supports `content-length-range` condition match type.  | 
| Cache-Control `Content-Type` `Content-Disposition` `Content-Encoding` `Expires` |  REST-specific headers. For more information, see [POST Object](RESTObjectPOST.md). This condition supports exact matching and `starts-with` condition match type.  | 
| key |  The acceptable key name or a prefix of the uploaded object. This condition supports exact matching and `starts-with` condition match type.  | 
| success\$1action\$1redirect `redirect` |  The URL to which the client is redirected upon successful upload. This condition supports exact matching and `starts-with` condition match type.  | 
| success\$1action\$1status |  The status code returned to the client upon successful upload if `success_action_redirect` is not specified. This condition supports exact matching.  | 
| x-amz-algorithm |  The signing algorithm that must be used during signature calculation. For AWS Signature Version 4, the value is `AWS4-HMAC-SHA256`.  This condition supports exact matching.  | 
| x-amz-credential |  The credentials that you used to calculate the signature. It provides access key ID and scope information identifying region and service for which the signature is valid. This should be the same scope you used in calculating the signing key for signature calculation.  It is a string of the following form: `<your-access-key-id>/<date>/<aws-region>/<aws-service>/aws4_request` For example: ` AKIAIOSFODNN7EXAMPLE/20130728/us-east-1/s3/aws4_request` For Amazon S3, the aws-service string is `s3`. For a list of Amazon S3 `aws-region` strings, see [Regions and Endpoints](https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region) in the *AWS General Reference*. This is required if a POST policy document is included with the request. This condition supports exact matching.  | 
| x-amz-date |  The date value specified in the ISO8601 formatted string. For example, `20130728T000000Z`. The date must be same that you used in creating the signing key for signature calculation. This is required if a POST policy document is included with the request. This condition supports exact matching.  | 
| x-amz-security-token |  Amazon DevPay security token.  Each request that uses Amazon DevPay requires two `x-amz-security-token` form fields: one for the product token and one for the user token. As a result, the values must be separated by commas. For example, if the user token is `eW91dHViZQ==` and the product token is `b0hnNVNKWVJIQTA=`, you set the POST policy entry to: `{ "x-amz-security-token": "eW91dHViZQ==,b0hnNVNKWVJIQTA=" }`. For more information about Amazon DevPay, see [Using DevPay](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingDevPay.html) in the *Amazon Simple Storage Service User Guide*.  | 
| x-amz-meta-\$1 |  User-specified metadata.  This condition supports exact matching and `starts-with` condition match type.   | 
| x-amz-\$1 |  See POST Object ([POST Object](RESTObjectPOST.md) for other `x-amz-*` headers.  This condition supports exact matching.  | 

**Note**  
 If your toolkit adds more form fields (for example, Flash adds `filename`), you must add them to the POST policy document. If you can control this functionality, prefix `x-ignore-` to the field so Amazon S3 ignores the feature and it won't affect future versions of this feature. 

## Character Escaping
<a name="sigv4-HTTPPOSTEscaping"></a>

Characters that must be escaped within a POST policy document are described in the following table.


|  Escape Sequence  |  Description  | 
| --- | --- | 
|  \$1\$1  |  Backslash  | 
|  \$1\$1  |  Dollar symbol  | 
|  \$1b  |  Backspace  | 
|  \$1f  |  Form feed  | 
|  \$1n  |  New line  | 
|  \$1r  |  Carriage return  | 
|  \$1t  |  Horizontal tab  | 
|  \$1v  |  Vertical tab  | 
|  \$1u*xxxx*  |  All Unicode characters  | 

Now that you are acquainted with forms and policies, and understand how signing works, you can try a POST upload example. You need to write the code to calculate the signature. The example provides a sample form, and a POST policy that you can use to test your signature calculations. For more information, see [Example: Browser-Based Upload using HTTP POST (Using AWS Signature Version 4)](sigv4-post-example.md).

# Example: Browser-Based Upload using HTTP POST (Using AWS Signature Version 4)
<a name="sigv4-post-example"></a>

This section shows an example of using an HTTP POST request to upload content directly to Amazon S3.

For more information on Signature Version 4, see [Signature Version 4 Signing Process](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html).

## Uploading a File to Amazon S3 Using HTTP POST
<a name="sigv4-post-example-file-upload"></a>

This example provides a sample POST policy and a form that you can use to upload a file. The topic uses the example policy and fictitious credentials to show you the workflow and resulting signature and policy hash. You can use this data as test suite to verify your signature calculation code.

The example uses the following example credentials the signature calculations. You can use these credentials to verify your signature calculation code. However, you must then replace these with your own credentials when sending requests to AWS.


| Parameter | Value | 
| --- | --- | 
| AWSAccessKeyId | AKIAIOSFODNN7EXAMPLE | 
| AWSSecretAccessKey | wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY | 

### Sample Policy and Form
<a name="sigv4-post-example-file-upload-policy"></a>

The following POST policy supports uploads to Amazon S3 with specific conditions.

```
 1. { "expiration": "2015-12-30T12:00:00.000Z",
 2.   "conditions": [
 3.     {"bucket": "sigv4examplebucket"},
 4.     ["starts-with", "$key", "user/user1/"],
 5.     {"acl": "public-read"},
 6.     {"success_action_redirect": "http://sigv4examplebucket.s3.amazonaws.com/successful_upload.html"},
 7.     ["starts-with", "$Content-Type", "image/"],
 8.     {"x-amz-meta-uuid": "14365123651274"},
 9.     {"x-amz-server-side-encryption": "AES256"},
10.     ["starts-with", "$x-amz-meta-tag", ""],
11. 
12.     {"x-amz-credential": "AKIAIOSFODNN7EXAMPLE/20151229/us-east-1/s3/aws4_request"},
13.     {"x-amz-algorithm": "AWS4-HMAC-SHA256"},
14.     {"x-amz-date": "20151229T000000Z" }
15.   ]
16. }
```

This POST policy sets the following conditions on the request:
+ The upload must occur before noon UTC on December 30, 2015.
+ The content can be uploaded only to the `sigv4examplebucket`. The bucket must be in the region that you specified in the credential scope (`x-amz-credential` form parameter), because the signature you provided is valid only within this scope.
+ You can provide any key name that starts with `user/user1`. For example, `user/user1/MyPhoto.jpg`.
+ The ACL must be set to `public-read`.
+ If the upload succeeds, the user's browser is redirected to `http://sigv4examplebucket.s3.amazonaws.com/successful_upload.html`.
+ The object must be 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 POST policy. You use this value as your StringToSign in signature calculation.

```
1. eyAiZXhwaXJhdGlvbiI6ICIyMDE1LTEyLTMwVDEyOjAwOjAwLjAwMFoiLA0KICAiY29uZGl0aW9ucyI6IFsNCiAgICB7ImJ1Y2tldCI6ICJzaWd2NGV4YW1wbGVidWNrZXQifSwNCiAgICBbInN0YXJ0cy13aXRoIiwgIiRrZXkiLCAidXNlci91c2VyMS8iXSwNCiAgICB7ImFjbCI6ICJwdWJsaWMtcmVhZCJ9LA0KICAgIHsic3VjY2Vzc19hY3Rpb25fcmVkaXJlY3QiOiAiaHR0cDovL3NpZ3Y0ZXhhbXBsZWJ1Y2tldC5zMy5hbWF6b25hd3MuY29tL3N1Y2Nlc3NmdWxfdXBsb2FkLmh0bWwifSwNCiAgICBbInN0YXJ0cy13aXRoIiwgIiRDb250ZW50LVR5cGUiLCAiaW1hZ2UvIl0sDQogICAgeyJ4LWFtei1tZXRhLXV1aWQiOiAiMTQzNjUxMjM2NTEyNzQifSwNCiAgICB7IngtYW16LXNlcnZlci1zaWRlLWVuY3J5cHRpb24iOiAiQUVTMjU2In0sDQogICAgWyJzdGFydHMtd2l0aCIsICIkeC1hbXotbWV0YS10YWciLCAiIl0sDQoNCiAgICB7IngtYW16LWNyZWRlbnRpYWwiOiAiQUtJQUlPU0ZPRE5ON0VYQU1QTEUvMjAxNTEyMjkvdXMtZWFzdC0xL3MzL2F3czRfcmVxdWVzdCJ9LA0KICAgIHsieC1hbXotYWxnb3JpdGhtIjogIkFXUzQtSE1BQy1TSEEyNTYifSwNCiAgICB7IngtYW16LWRhdGUiOiAiMjAxNTEyMjlUMDAwMDAwWiIgfQ0KICBdDQp9
```

When you copy/paste the preceding policy, it should have carriage returns and new lines for your computed hash to match this value (ie. ASCII text, with CRLF line terminators).

Using example credentials to create a signature, the signature value is as follows (in signature calculation, the date is same as the `x-amz-date` in the policy (20151229):

```
8afdbf4008c03f22c2cd3cdb72e4afbb1f6a588f3255ac628749a66d7f09699e
```

The following example form specifies the preceding POST policy and supports a POST request to the `sigv4examplebucket`. Copy/paste the content in a text editor and save it as exampleform.html. You can then upload image files to the specific bucket using the exampleform.html. Your request will succeed if the signature you provide matches the signature Amazon S3 calculates.

**Note**  
You must update the bucket name, dates, credential, policy, and signature with valid values for this to successfully upload to S3. 

```
 1. <html>
 2.   <head>
 3.     
 4.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 5.     
 6.   </head>
 7.   <body>
 8. 
 9.   <form action="http://sigv4examplebucket.s3.amazonaws.com/" method="post" enctype="multipart/form-data">
10.     Key to upload: 
11.     <input type="input"  name="key" value="user/user1/${filename}" /><br />
12.     <input type="hidden" name="acl" value="public-read" />
13.     <input type="hidden" name="success_action_redirect" value="http://sigv4examplebucket.s3.amazonaws.com/successful_upload.html" />
14.     Content-Type: 
15.     <input type="input"  name="Content-Type" value="image/jpeg" /><br />
16.     <input type="hidden" name="x-amz-meta-uuid" value="14365123651274" /> 
17.     <input type="hidden" name="x-amz-server-side-encryption" value="AES256" /> 
18.     <input type="text"   name="X-Amz-Credential" value="AKIAIOSFODNN7EXAMPLE/20151229/us-east-1/s3/aws4_request" />
19.     <input type="text"   name="X-Amz-Algorithm" value="AWS4-HMAC-SHA256" />
20.     <input type="text"   name="X-Amz-Date" value="20151229T000000Z" />
21. 
22.     Tags for File: 
23.     <input type="input"  name="x-amz-meta-tag" value="" /><br />
24.     <input type="hidden" name="Policy" value='<Base64-encoded policy string>' />
25.     <input type="hidden" name="X-Amz-Signature" value="<signature-value>" />
26.     File: 
27.     <input type="file"   name="file" /> <br />
28.     <!-- The elements after this will be ignored -->
29.     <input type="submit" name="submit" value="Upload to Amazon S3" />
30.   </form>
31.   
32. </html>
```

The post parameters are case insensitive. For example, you can specify `x-amz-signature` or `X-Amz-Signature`.

# Browser-based uploads to Amazon S3 using the AWS Amplify library
<a name="browser-based-uploads-aws-amplify"></a>

This section describes how to upload files to Amazon S3 using the AWS Amplify JavaScript library.

For information about setting up the AWS Amplify library, see [AWS Amplify Installation and Configuration](https://aws.github.io/aws-amplify/).

## Using the AWS Amplify JavaScript library to Upload Files to Amazon S3
<a name="browser-based-uploads-aws-amplify-example"></a>

The AWS Amplify library `Storage` module gives a simple browser-based upload mechanism for managing user content in public or private Amazon S3 storage. 

**Example : AWS Amplify Manual Setup**  
The following example shows the manual setup for using the AWS Amplify Storage module. The default implementation of the Storage module uses Amazon S3.   

```
import Amplify from 'aws-amplify';
Amplify.configure(
    Auth: {
        identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab', //REQUIRED - Amazon Cognito Identity Pool ID
        region: 'XX-XXXX-X', // REQUIRED - Amazon Cognito Region
        userPoolId: 'XX-XXXX-X_abcd1234', //OPTIONAL - Amazon Cognito User Pool ID
        userPoolWebClientId: 'XX-XXXX-X_abcd1234', //OPTIONAL - Amazon Cognito Web Client ID
    },
    Storage: {
        bucket: '', //REQUIRED -  Amazon S3 bucket
        region: 'XX-XXXX-X', //OPTIONAL -  Amazon service region
    }
);
```

**Example : Put data into Amazon S3**  
The following example shows how to `put` public data into Amazon S3.  

```
Storage.put('test.txt', 'Hello')
        .then (result => console.log(result))
        .catch(err => console.log(err));
```
The following example shows how to `put` private data into Amazon S3.  

```
Storage.put('test.txt', 'Private Content', {
        level: 'private',
        contentType: 'text/plain'
    })
    .then (result => console.log(result))
    .catch(err => console.log(err));
```

For more information about using the AWS Amplify Storage module, see [AWS Amplify Storage](https://aws.github.io/aws-amplify/media/storage_guide.html).

## More Info
<a name="browser-based-uploads-moreinfo"></a>

[AWS Amplify Quick Start](https://aws.github.io/aws-amplify/)