This library will let you perform certain commands on the new Rackspace php-opencloud API. Currently the following methods are available:
- Creating a Container
- Deleting a Container
- Listing all Containers
- Listing all objects in a Container
- Adding an Object to a Container
- Deleting an Object from Container
Drop the files/folders in the /application folder into your CodeIgniter /application folder. You will then need to modify the contents of /application/config/opencloud.php to match your Rackspace account.
You can load the library in any controller you would like to use it in like this:
$this->load->library('opencloud');All methods return a boolean value and the last error message can be grabbed by calling $this->opencloud->error ex:
if ($this->opencloud->create_container('MyContainer')) {
// Container created successfully
} else {
echo $this->opencloud->error;
}You can create a container like so:
$this->opencloud->create_container('MyContainer');This will automatically make the container CDN enabled.
A container must be empty before it can be deleted.
$this->opencloud->delete_container('MyContainer');$containers = $this->opencloud->list_containers();This will return a multi-dimentional array containing name, count, bytes for each container.
You will need to set the container first by using the method set_container()
$this->opencloud->set_container('MyContainer');
$objects = $this->opencloud->list_objects();This will return a multi-dimentional array containing name, content_type, bytes and cdn-url for each object.
You will need to set the container first by using the method set_container()
$this->opencloud->set_container('MyContainer');
$this->opencloud->add_object('my_photo.img', 'path_to/my_photo.jpg','image/jpeg');The first parameter will be the name you will assign the object, the second is the path of the file, and the third will be the Content-type of the file (this is optional).
You will need to set the container first by using the method set_container()
$this->opencloud->set_container('MyContainer');
$this->opencloud->delete_object('text1.txt');
$this->opencloud->delete_object('text2.txt');
$this->opencloud->delete_object('text3.txt');