Rackspace Cloud FIles Bulk Delete objects prefixed/* wildcard php sdk

Hi Guys


Rackspace cloud files is an awesome file storage system, We upload a file and can make it publicly available through their CDN.

While I use Cloud files in pretty much all my projects at work or personal stuff, one thing that I did today was to delete objects with specific prefix


Lets say I have these objects under container “jcorg”

  • hello
  • hello1
  • hello2
  • anothervaluableobject

and I want to delete all objects whose name starts with hello

Here is a code snippet that will be handy for you

Language: PHP
API link: https://github.com/rackspace/php-opencloud

and of course you can use equivalent code in other language SDKs too



Code Snippet

Let me give you a brief overview to you

  1. First we are creating a connection to Rackspace server, depending on which region you are in you will use either RACKSPACE_US or RACKSPACE_UK to authenticate your request.
  2. Then we are connection to our object store
  3. Then we are getting hold of object list where name or an object starts with “hello
  4. Finally we are iterating on objects found and deleting them. You can check object name here to just to filter them out before you process them for deletion

I hope this makes sense, but just in case if you have a question, do leave your comment.



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.