Skip to content

aeperezt/php-opencloud-for-codeigniter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

PHP-OpenCloud Library for CodeIgniter

This library will let you perform certain commands on the new Rackspace php-opencloud API. Currently the following methods are available:

Installation

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.

Usage

You can load the library in any controller you would like to use it in like this:

$this->load->library('opencloud');

Error Handling

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;
}

Creating a Container

You can create a container like so:

$this->opencloud->create_container('MyContainer');

This will automatically make the container CDN enabled.

Deleting a Container

A container must be empty before it can be deleted.

$this->opencloud->delete_container('MyContainer');

Listing all Containers

$containers = $this->opencloud->list_containers();

This will return a multi-dimentional array containing name, count, bytes for each container.

Listing all Objects in a 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.

Adding objects in a Container

You will need to set the container first by using the method set_container()

$this->opencloud->set_container('MyContainer');
$this->opencloud->add_object('text1.txt', file_get_contents('files/text1.txt'), 'text/plain');
$this->opencloud->add_object('text2.txt', file_get_contents('files/text2.txt'), 'text/plain');
$this->opencloud->add_object('text3.txt', file_get_contents('files/text3.txt'), 'text/plain');

The first paramater will be the name you will assign the object, the second is the contents of the file, and the third will be the Content-type of the file.

Deleting Objects from a Container

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');

About

CodeIgniter Rackspace php-opencloud for CloudFiles

Resources

Stars

Watchers

Forks

Packages

No packages published