Can’t return the amount of objects in a container?

Question:

I am attempting to return the amount of objects in a container. When loading the page it shows only the bit of text ‘number of objects: ‘ and no number.

No errors show when loading the page, its connecting to the cloud and the container name is correct too.

Code:

Code:
require('../../rackspace_store/cloudfiles.php');

 // cloud info
 $username = "username"; 
 $key = "key"; 

 // Connect to Rackspace
 $auth = new CF_Authentication($username, $key);
 $auth->authenticate();
 $conn = new CF_Connection($auth);
 $files = $conn->get_container("containername");
 print "Number of Objects: ". $files->count ."\n";
 $conn->close();

Answers:

$c =$ conn->get_container(“my_container”);
$c->object_count;
$c->bytes_used;

object_count and bytes_used should give you the two attributes you are looking for.

Rackspace Secrets

Leave a Reply

Your email address will not be published. Required fields are marked *