Create or update object metadata

 
MethodURIDescription
POST/v1/{account}/{container}/{object}

Creates or updates object metadata.

To create or update custom metadata, use the X-Object-Meta-{name} header, where {name} is the name of the metadata item.

In addition to the custom metadata, you can also update these system metadata items: Content-Type Content-Encoiding Content-Disposition X-Delete-At. However you cannot update other system metadata such as Content-Length or Last-Modified.

You can use COPY as an alternate to the POST operation by copying to the same object. With the POST operation you must specify all metadata items, whereas with the COPY operation, you need to specify only changed or additional items.

All metadata is preserved during the object copy. If you specify metadata on the request to copy the object, either PUT or COPY, the metadata overwrites any conflicting keys on the target (new) object.

A POST request deletes any existing custom metadata that you added with a previous PUT or POST request. Consequently, you must specify all custom metadata in the request. However, system metadata is unchanged by the POST request unless you explicitly supply it in a request header.

You can also set the X-Delete-At or X-Delete-After header to define when to expire the object.

When used as described in this section, the POST operation creates or replaces metadata. This form of the operation has no request body. The form POST feature can also use the POST operation to upload objects. For more information about form POST see OpenStack Object Storage API v1 Reference .

Example requests and responses:

  • Create object metadata:

    curl -i $publicURL/marktwain/goodbye -X POST -H "X-Auth-Token: $token" -H "X-Object-Meta-Book: GoodbyeColumbus"

    HTTP/1.1 202 Accepted
    Content-Length: 76
    Content-Type: text/html; charset=UTF-8
    X-Trans-Id: txb5fb5c91ba1f4f37bb648-0052d84b3f
    Date: Thu, 16 Jan 2014 21:12:31 GMT
    
    <html><h1>Accepted</h1><p>The request is accepted for processing.</p></html>

  • Update object metadata:

    curl -i $publicURL/marktwain/goodbye -X POST -H "X-Auth-Token: $token" -H "X-Object-Meta-Book: GoodbyeOldFriend"

    HTTP/1.1 202 Accepted
    Content-Length: 76
    Content-Type: text/html; charset=UTF-8
    X-Trans-Id: tx5ec7ab81cdb34ced887c8-0052d84ca4
    Date: Thu, 16 Jan 2014 21:18:28 GMT
    
    <html><h1>Accepted</h1><p>The request is accepted for processing.</p></html>

For a complete description of HTTP 1.1 header definitions, see Header Field Definitions.

Normal response codes: 202

 Request

This table shows the header parameters for the create or update object metadata request:

NameTypeDescription

X-Auth-Token

​String

(Optional)

Authentication token. If you omit this header, your request fails unless the account owner has granted you access through an access control list (ACL).

X-Object-Meta-name

​String

(Optional)

The container metadata, where {name} is the name of the metadata item.

You must specify a X-Object-Meta-{name} header for each metadata item (for each {name}) that you want to add or update.

X-Delete-At

​Int

(Optional)

The certain date, in the format of a UNIX Epoch timestamp, when the object is removed.

Content-Disposition

​String

(Optional)

If set, specifies the override behavior for the browser. For example, this header might specify that the browser use a download program to save this file rather than show the file, which is the default.

Content-Encoding

​String

(Optional)

If set, the value of the Content-Encoding metadata.

X-Delete-After

​Int

(Optional)

Specifies the number of seconds after which the object is removed. Internally, the Object Storage system stores this value in the X-Delete-At metadata item.

Content-Type

​String

(Optional)

Changes the MIME type for the object.

X-Detect-Content-Type

​Boolean

(Optional)

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

This table shows the URI parameters for the create or update object metadata request:

NameTypeDescription

{account}

​String

The unique name for the account. An account is also known as the project or tenant.

{container}

​String

The unique name for the container.

{object}

​String

The unique name for the object.

 Response

This table shows the header parameters for the create or update object metadata response:

NameTypeDescription

Content-Length

​String

(Required)

If the operation succeeds, this value is zero (0). If the operation fails, this value is the length of the error text in the response body.

Content-Type

​String

(Required)

The MIME type of the object.

X-Trans-Id

​Uuid

(Required)

A unique transaction identifier for this request. Your service provider might need this value if you report a problem.

Date

​Datetime

(Required)

The transaction date and time.

Questions? Discuss on ask.openstack.org
Found an error? Report a bug against this page

loading table of contents...