• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (OBS)
  4. Operations on Objects
  5. POST Object
  6. Requests

Requests

Syntax

POST / HTTP/1.1 
 Host: bucketname.obs.example.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" 
 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" 
 Content-Type: image/jpeg 
 file_content 
 --9431149156168 
 Content-Disposition: form-data; name="submit" 
 Upload to OBS 
 --9431149156168--

Request Parameters

This request involves no parameters.

Request Headers

This request uses common headers. For details about common request headers, see section Common Request Headers. If you want to obtain CORS configuration information, you must use the headers in Table 1.

Table 1 Request headers of CORS configuration

Header

Description

Remarks

Origin

Indicates an origin specified by a pre-request. Generally, it is a domain name.

Type: String

Mandatory

Access-Control-Request-Headers

Indicates the HTTP headers of a request. The request can use multiple HTTP headers.

Type: String

Optional

x-amz-security-token

Header field used to identify the request of a federated user. When the federal authentication function is enabled, users sending such requests are identified as federated users.

Type: string

Optional. This parameter must be carried in the request sent by federated users.

Request Elements

This request uses form fields. Table 2 describes the form fields.

Table 2 Form fields

Form Field

Description

Remarks

file

Indicates the content of the object to be uploaded.

Type: Binary or text content

Constraints: This field must be the last one in a form. Each request can contain only one file field. All excessive file fields are discarded.

Mandatory

key

Indicates the name of the object to be uploaded.

Type: String

Mandatory

AWSAccessKeyId

Indicates the AK of the requester.

Type: String

Constraints: Required if the policy field is included in the request.

Optional

policy

Indicates the security policy of the request.

Type: String

Optional

expires

Indicates the date and time at which an object is no longer cacheable. The time is expressed in milliseconds in RFC 2616 format. If this field is specified, it will be returned in response headers after you send a GET Object or HEAD Object request.

Type: String

Example:

Policy: {" expires ": "1000" }

HTML: <input type="text" name=" expires " value="1000" />

Optional

x-amz-acl

Indicates the ACL applied to the object to be uploaded. Possible values are privatepublic-readpublic-read-writeauthenticated-readbucket-owner-read, and bucket-owner-full-control. For details, see Table 4.

Type: String

Example:

Policy: {"acl": "public-read" }

HTML:<input type="text" name="acl" value="public-read" />

Optional

x-amz-storage-class

When creating an object, you can add this header in the request to set the storage class of the object. If you do not add this header, the object will use the default storage class of the bucket.

Type: String

Note: The storage class can be STANDARD (OBS Standard), STANDARD_IA (OBS Warm), or GLACIER (OBS Cold). Note that the three storage class values are case-sensitive.

Example: x-amz-storage-class: STANDARD

Optional

Cache-Control, Content-Type, Content-Disposition, Content-Encoding

Indicate standard HTTP headers. If these fields are specified, they are returned in response headers after you send a GET Object or HEAD Object request.

Type: String

Example:

Policy: ["starts-with", "$Content-Type", "text/"]

HTML: <input type="text" name="content-type" value="text/plain" />

Optional

success_action_redirect

Indicates the URL to which the client is redirected after the request is successfully responded to.

  • If the value is valid and the request is successful, OBS returns status code 303. Location contains success_action_redirect, bucket name, object name, and object ETag.
  • If the value is invalid, OBS ignores this field and returns status code 204. Location contains the object address.

Type: String

Example:

Policy: {"success_action_redirect": "http://123458.com"}

HTML: <input type="text" name="success_action_redirect" value="http://123458.com" />

Optional

x-amz-meta-*

This prefix is used to construct a field in a POST request for returning self-defined metadata. If this prefix is specified, user-defined metadata is returned in one or more response headers prefixed with x-amz-meta-.

Note: The format of the user-defined metadata header is x-amz-meta-key:value. The total size of the key and value of all user-defined metadata in the request cannot exceed 2 KB.

Type: String

Example:

Policy: {" x-amz-meta-test ": " test metadata " }

HTML: <input type="text" name=" x-amz-meta-test " value=" test metadata " />

Optional

success_action_status

Indicates the status code returned after a POST Object request is successfully received. Possible values are 200201, and 204.

  • If the value is set to 200 or 204, OBS returns an empty response body.
  • If the value is set to 201, OBS returns a response containing an XML file recording request details.
  • If the value is not set or is invalid, OBS returns status code 204.

Type: String

Example:

Policy: ["starts-with", "$success_action_status", ""]

HTML: <input type="text" name="success_action_status" value="200" />

Optional

x-amz-website-redirect-location

If a bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. OBS stores the value of this header in the object metadata.

Default: None

Constraint: The value must be prefixed by a slash (/), http://, or https://. The length of the value cannot exceed 2 K.

Optional

x-amz-server-side-encryption

Indicates that SSE-KMS is used.

Type: string

Example: x-amz-server-side-encryption:aws:kms

No. This header is mandatory when KMS-managed keys are used.

x-amz-server-side-encryption-aws-kms-key-id

Indicates the master key ID. This header is used in SSE-KMS mode. If the customer does not provide the master key, the default master key will be used.

Type: string

Example: x-amz-server-side-encryption-aws-kms-key-id:arn:aws:kms:sichuan:domainiddomainiddomainiddoma0001:key/4f1cd4de-ab64-4807-920a-47fc42e7f0d0

No

x-amz-server-side-encryption-customer-algorithm

Indicates an encryption algorithm. The header is used in SSE-C mode.

Type: string

Example: x-amz-server-side-encryption-customer-algorithm:AES256

Constraints: This header must be used together with x-amz-server-side-encryption-customer-key and x-amz-server-side-encryption-customer-key-MD5.

No. This header is mandatory when customer-provided keys are used.

x-amz-server-side-encryption-customer-key

Indicates a key used to encrypt objects. The header is used in SSE-C mode.

Type: string

Example: x-amz-server-side-encryption-customer-key:K7QkYpBkM5+hcs27fsNkUnNVaobncnLht/rCB2o/9Cw=

Constraints: This header is a base64-encoded 256-bit or 512-bit key and must be used together with x-amz-server-side-encryption-customer-algorithm and x-amz-server-side-encryption-customer-key-MD5.

No. This header is mandatory when customer-provided keys are used.

x-amz-server-side-encryption-customer-key-MD5

Indicates the MD5 value of a key used to encrypt objects. The header is used in SSE-C mode. The MD5 value is used to check whether any error occurs during the transmission of the key.

Type: string

Example: x-amz-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ==

Constraints: This header is a base64-encoded 128-bit MD5 value and must be used together with x-amz-server-side-encryption-customer-algorithm and x-amz-server-side-encryption-customer-key.

No. This header is mandatory when customer-provided keys are used.