Rackspace Cloud Files: How To Use Expiring Objects API Functionality

We frequently update our products, and Cloud Files is no exception. In this series of technical posts, we’ll dig into how developers using the Cloud Files API can leverage new capabilities in Rackspace Cloud Files.

If you don’t need or want to keep Cloud Files objects indefinitely (e.g. log files or recurring full backups), simply add a header while uploading the object to set when it will be automatically removed from your Cloud Files account.

When an object is assigned either an X-Delete-After or X-Delete-At header when doing a PUT or POST on the object, it is scheduled for deletion. The X-Delete-At header requires a Unix Epoch timestamp, in integer form; for example, 1348691905 represents Wed, 26 Sep 2012 20:38:25 GMT. By setting the header to a specific Epoch time, you indicate when you want the object to expire, not be served, and be deleted completely from the storage system.

The X-Delete-After header takes an integer number of seconds and calculates the amount of time from now that you want the object to be deleted. The proxy server that receives the request converts this header into an X-Delete-At header and calculates the deletion time using its current time plus the value given in seconds.

For existing objects that you want to assign expiration headers to, use the POST operation.

Example: Delete At Example

In the example, the X-Delete-At header is assigned with a Unix Epoch timestamp in integer form for Mon, 11 Jun 2012 15:38:25 GMT. Use http://www.epochconverter.com/ for example timestamps and a batch converter.

PUT /<api version>/<account>/<container>/<object> HTTP/1.1
  Host: storage.clouddrive.com
  X-Auth-Token: eaaafd18-0fed-4b3a-81b4-663c99ec1cbb
  Content-Type: image/jpeg
    X-Delete-At: 1339429105

Example:  Delete After Example

In this example, the X-Delete-After header is assigned a value in seconds, equivalent to 10 days. After this time, the object shall expire.

  PUT /<api version>/<account>/<container>/<object> HTTP/1.1
  Host: storage.clouddrive.com
  X-Auth-Token: eaaafd18-0fed-4b3a-81b4-663c99ec1cbb
  Content-Type: image/jpeg
  X-Delete-After: 864000

This is just one of many new features in Rackspace Cloud Files that developers can take advantage of. Cloud Files customers are urged to try out this new feature in their next API project or add it to a current application. If you’re not yet using Cloud Files, sign up for an account and check it out. And now, using Cloud Files is more affordable since we reduced the cost of Cloud Files by 33 percent.

Be sure to check out our previous post detailing how to create a static website with Cloud Files.

  • What are the accepted values for “X-Delete-At”? Let’s say I changed my mind after adding a future date to delete the object and I want the object to no expire, ie: give it a negative value or remove the property so that the file won’t get deleted/expired?

    • Jerry Schwartz

      Accepted values are in unix epoch time. To remove the metadata, send the header with a null value. (blank). Negative values are not accepted.


    • Thank you Jerry!

  • Unfortunately this does not seem to work consistently. http://c390373.r73.cf1.rackcdn.com/c061f6e8-47a4-4512-aad8-c6d3807da1de.gif is a sample file, the header says x-delete-at:1342568343 and this file should have been deleted at Tuesday, July 17, 2012 6:39:03 PM.

    More than half of the time when I try to remove the x-delete-at(pass value null) I get an error, “bad request”