Updating the metadata of an object
You use the HTTP POST method to create or update object metadata. To create or update object metadata, you need the write permission for the target container.
If you use the POST method on an object that already has custom metadata, the request overwrites the existing custom metadata. If you want to retain old metadata, you need to include it in the request.
Request line
Depending on whether the HSwift request uses a Keystone tenant ID or the account name, the request line for a request to update the metadata of an object has either of these formats:
- With the Keystone tenant ID:
POST /swift/v1/tenant-ID/container-name/directory-name/object-name HTTP/1.1
- With the account name:
OST /swift/v1/account-name/container-name/directory-name/object-name HTTP/1.1
Request headers
The table below describes the headers you can use in a request to update the metadata of an object.
Name | Type | Description |
X-Auth-Token | String |
Used to supply the Keystone authentication token or local authentication token. Replace the Keystone authentication token with the prefix HCP, followed by your Local Authentication token, in the format: "X-Auth-Token: HCP base64-encoded-username:md5-encoded-password" For example: "X-Auth-Token: HCP bGdyZWVu:a3b9c163f6c520407ff34cfdb83ca5c6" |
X-Object-Meta-name | String | For objects only, specifies a custom metadata property/value pair. The response headers include one X-Object-Meta- header for each applicable pair. |
Response headers
The table below describes the headers you can use in a request to update the metadata of an object.
Name | Type | Description |
Content-length | String (Required) |
The size, in bytes, of the response body if HCP can determine the size before formulating the response. If the response does not include a response body, the value of the |
Content-Type | String (Required if the Content-Length is greater than 0) |
The Internet media type of the response body if HCP can determine the Internet media type. If HCP cannot determine the Internet media type, the value of this header is Because HCP returns error information in a response body, the response to any request can include a |
Date | Datetime (Required) |
The date and time at which HCP responded to the request in Greenwich Mean Time (GMT). The date and time are returned in this format: DDD dd MMM yyyy HH:mm:ss GMT For example: Thu, 14 Mat 2013 14:27:05 GMT |
X-Trans-Id | Uuid (Required) | HCP returns a universally unique identifier (UUID). This UUID does not map to any entries in the HCP database. |
HTTP status codes
The table below describes HTTP status code that is returned in response to a request to create or update the metadata of an object.
Code | Meaning | Description |
200 | Success | The object metadata has been updated. |
Example: Updating the custom metadata of an object
Here's a sample POST request that updates the metadata of an object named sales_quotas_2013.pdf which has the existing custom metadata property/value pair business/campaign. The request updates the metadata property/value pair to business/finance.
Request with curl command line
curl -k -i -X POST http://api.hcp.example.com/swift/v1/AUTH_6b6884ebb6f441cfbb7e740f6a927c9e/finance/sales_quotas_2013.pdf -H "X-Auth-Token: dc5efec8f546455eac974e7bbfd0dd87" -H "X-Object-Meta-business: finance"
Request headers
POST /swift/v1/AUTH_6b6884ebb6f441cfbb7e740f6a927c9e/finance/sales_quotas_2013.pdf HTTP/1.1 X-Object-Meta-author: P.D Grey X-Object-Meta-Book: Book 1 X-Object-Meta-Info: Info 1 X-Auth-Token: dc5efec8f546455eac974e7bbfd0dd87
Response headers
HTTP/1.1 202 Accepted Content-Length: 76 Content-Type: text/html; charset=UTF-8 X-Trans-Id: tx4d9b4f1cd99e437fb9e79-0054206e7d Date: Mon, 22 Sep 2013 18:46:21 GMT