Deleting an object or directory
You use the HTTP DELETE method to delete an object or directory in a container. To check the delete an object or container, you need write permission for the container containing the object or directory.
Request line
Depending on whether the HSwift request uses a Keystone tenant ID or the account name, the request line for a request to delete an object has either of these formats:
- With the Keystone tenant ID included in the hostname:
DELETE /swift/v1/tenant-ID/container-name/directory-name/object-name HTTP/1.1
- With the account name following the hostname:
DELETE /swift/v1/account-name/container-name/directory-name/object-name HTTP/1.1
Depending on whether the HSwift request uses a Keystone tenant ID or the account name, the request line for a request to delete a directory has either of these formats:
- With the Keystone tenant ID included in the hostname:
DELETE /swift/v1/tenant-ID/container-name/directory-name/ HTTP/1.1
- With the account name following the hostname:
DELETE /swift/v1/account-name/container-name/directory-name/ HTTP/1.1
Request headers
The table below describes the headers you can use in a request to check the existence of an object or directory.
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" |
Response headers
The table below describes the response headers returned in response to a successful request to delete an object or directory.
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 codes that can be returned in response to a request to delete an object or directory.
Code | Meaning | Description |
204 | No Content | No Response Body. |
404 | Not Found | HTML error message in response body. |
500 | Internal Server Error |
An internal error occurred. If this error persists, contact your tenant administrator. |
503 | Service Unavailable |
HCP is temporarily unable to handle the request, probably due to system overload, maintenance, or upgrade. Try the request again, gradually increasing the delay between each successive attempt. If this error persists, contact your tenant administrator. |
Example: Deleting an object
Here's a sample DELETE request that deletes an object named hum_res/budget_proposals/BudgProp-2013 from the finance container.
Request with curl command line
curl -v -X -k DELETE http://api.hcp.example.com/swift/v1/AUTH_6b6884ebb6f441cfbb7e740f6a927c9e/finance/hum_res/budget_proposals/BudgProp-2013 -H "X-Auth-Token: dc5efec8f546455eac974e7bbfd0dd87"
Request headers
DELETE /swift/v1/AUTH_6b6884ebb6f441cfbb7e740f6a927c9e/finance/hum_res/budget_proposals/BudgProp-2013 HTTP/1.1 X-Auth-Token: dc5efec8f546455eac974e7bbfd0dd87
Response headers
HTTP/1.1 204 No Content Date: Mon, 03 Nov 2014 15:04:57 GMT Content-Type: text/html;charset=UTF-8 Content-Length: 538
Example: Deleting a directory
Here's a sample DELETE request that deletes a directory named hum_res/budget_proposals/ from the finance container.
Request with curl command line
curl -v -X -k DELETE http://api.hcp.example.com/swift/v1/AUTH_6b6884ebb6f441cfbb7e740f6a927c9e/finance/hum_res/budget_proposals/ -H "X-Auth-Token: dc5efec8f546455eac974e7bbfd0dd87"
Request headers
DELETE /swift/v1/AUTH_6b6884ebb6f441cfbb7e740f6a927c9e/finance/hum_res/budget_proposals/ HTTP/1.1 X-Auth-Token: dc5efec8f546455eac974e7bbfd0dd87
Response headers
HTTP/1.1 204 No Content Date: Mon, 03 Nov 2014 15:04:57 GMT