Support: 1-800-961-4454
Sales Chat
1-800-961-2888

Rackspace Cloud Files: How To Use Expiring Objects API Functionality

4

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.

About the Author

This is a post written and contributed by Jerry Schwartz.

Jerry is a Senior Product Marketing Manager focusing on our cloud storage and managed storage portfolios. He joined Rackspace in 2007 and was the Product Manager for our Microsoft applications including SharePoint, Exchange, SQL and the Windows Server operating system. He has worked in the Rackspace Cloud since 2010 shaping many of Rackspace’s cloud offerings including Cloud Files, Cloud Block Storage, Cloud Backup, and Cloud Servers.

Jerry is a loyal Texas Longhorns fan and received his MBA from the University of Texas at Austin. Outside of Rackspace, you will likely find him on a jet ski at one of the lakes around San Antonio.


More
4 Comments

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?

avatar wasulahewa on June 28, 2012 | Reply

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

Jerry

avatar Jerry Schwartz [Racker] on June 29, 2012

Thank you Jerry!

avatar wasulahewa on July 2, 2012

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”

avatar wasulahewa on July 18, 2012 | Reply

Leave a New Comment

(Required)


Racker Powered
©2014 Rackspace, US Inc.