• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Swift)
  4. Operations on Objects
  5. Create or Replace Object
  6. Request

Request

Method

Table 1 Method description

Method

URI

Description

PUT

/v1/{account}/{container}/{object}{?temp_url_sig,temp_url_expires,multipart-manifest}

Creates an object in the specified container.

{account} indicates the name of an account. {container} indicates the name of a container. {object} indicates the name of an object.

The request body of this operation is the object content.

Example Request

Create an object:

curl -i $publicURL/marktwain/helloworld.txt -X PUT 
 -H "X-Auth-Token: $token"

Request Query Parameters

Table 2 describes the query parameters for getting the object content:

Table 2 Request query parameters

Parameter

Type

Description

Required or Not

temp_url_sig

String

Used with TempURL to sign the request.

No

temp_url_expires

String

Used with TempURL to specify the expiry time of the signature.

No

multipart-manifest

String

If multipart-manifest=put is set, the object is a static large object manifest and the body contains the manifest.

No

Request Headers

Request URI parameters

Parameter

Type

Description

{account}

String

(Required)

Unique name of the account. In the current version, it indicates the unique ID of the account.

{container}

String

(Required)

Unique name of the container.

For details about container naming rules, see Naming Rules.

{object}

String

(Required)

Name of the object.

For details about object naming rules, see Object Naming Rules.

Table 3 Request header parameters

Header

Type

Description

X-Auth-Token

String

(Required)

Authentication token.

X-Object-Meta-name

String

(Optional)

Object metadata, where {name} is the name of the metadata item. To delete this item, send an empty value in this header. You must specify an X-Object-Meta-{name} header for each metadata item (for each {name}) that you want to add or update.

Content-Type

String

(Optional)

Sets the MIME type of the object.

X-Detect-Content-Type

Boolean

(Optional)

If it is set to true, OBS guesses the content type based on the file name extension and ignores the value sent in the Content-Type header, if present.

If-None-Match

String

(Optional)

Only an If-None-Match: * header can be specified. If an object already exists, the object fails to be created and a 412 status code is returned.

X-Object-Manifest

String

(Optional)

Set to specify that this is a dynamic large object manifest object. The value is the container and object name prefix of the segment objects in the form of container/prefix. The UTF-8 encoding format must be used.

Content-Length

String

(Optional)

Set to the length of the object content. Do not set if chunked transfer encoding is being used.

Transfer-Encoding

String

(Optional)

Set to chunked to enable chunked transfer encoding. If used, the Content-Length header is ignored.

X-Copy-From

String

(Optional)

The format is {container}/{object}. When this header is set, {container}/{object} is copied to create an object. The UTF-8 encoding format must be used.

Using PUT with X-Copy-From has the same effect as using the COPY operation to copy an object.

Using PUT with X-Copy-From has the same effect as COPY to create an object.

ETag

String

(Optional)

MD5 checksum value of the request body. If the MD5 checksum value of the request body is equal to the value of ETag, the upload is successful. If not equal, a 422 status code is returned.

It is recommended to check the MD5 checksum value for an upload.

Content-Disposition

String

(Optional)

Sets the value to {newname}. When an object is downloaded through a browser, the default object name {newname} is returned.

Content-Encoding

String

(Optional)

If this header is set, the value is the encoding format used when an object is downloaded through a browser.

NOTE:

If chunked transfer encoding is used and the value of Content-Length in a request is greater than the actual length of an object to be uploaded, OBS (compatible with OpenStack Swift) returns a 201 status code to indicate that the object is created successfully. In the same scenario, however, OpenStack Swift returns a 408 (Request Timeout) status code but the object is created successfully.