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.