I have the PHP library from Rackspace. We keep all files in a Container called 'data'. Within that container is a hierarchical directory of files.
I am able to rename or move an object, no problem (wrapped in my own class):
$this->container->move_object_to('uploads/files/file.txt', 'data', 'uploads/files2/filecopy.txt');
But I'm not able to do the same with a folder:
$this->container->move_object_to('uploads/files', 'data', 'uploads/files2');
So I thought instead, I'd get all objects in a folder and copy each individually. But I'm only able to get objects in a container:
$container = $this->connection->get_container('data');
$files = $container->list_objects();
this doesn't work:
$container = $this->connection->get_container('data/uploads');
$files = $container->list_objects();
How can I rename a folder? Or alternatively, move all objects in a folder to a new one?
You can list objects by pseudo folder by specifying a prefix in your list_objects() call. Here is the usage of the function:
list_objects($limit=0, $marker=NULL, $prefix=NULL, $path=NULL)
So something along the lines of this should work:
$container = $this->connection->get_container('data');
$files = $container->list_objects(0, NULL, 'uploads/');
You'd then loop through and copy all the returned objects.
-Mark