Swift is the OpenStack object storage service. In the Php-opencloud library, the ObjectStore class (OpenStack or Rackspace) created by the Connection object is accessed. For example: $cloud = new \opencloud\openstack (Array ( ' username ' => ' {username} ', ' Password ' => ') { Password} ')); $swift = $cloud->objectstore (' cloudfiles ', ' DFW '); With the newly created $swift, you can use different object storage components. The highest level of object storage component instances is that the Container,container is the collection name of the object, similar to the directory and folder in the file system (in fact, not equivalent). All objects are stored in the container. Enumerating all container Containerlist objects in an object storage instance is a collection of container objects. Enumerates all container in the object store instance: $containers = $swift->containerlist (); while ($container = $containers->next ()) printf ("%s\n", $container->name); Like a collection of other objects, this also supports the (a), Next (), and size () methods. Create a new container use the container () method of the newly created $swift object to create a new (empty) container. $mycontainer = $swift->container (); Save the container to an object storage instance using the Create () method: $mycontainer->create (' mycontainername '); Name does not have to be in the Create () method, if name is already set. It is also convenient to specify a name directly in the method. $mycontainer->name = ' mycontainername '; $mycontainer->create(); Retrieving an existing container if you pass a parameter to the ObjectStore object's container () method, you can retrieve an existing container: $oldcontainer = $swift-> Container (' Someoldcontainer '); In this case, the information about the Someoldcontainer will be retrieved. This contains the container metadata information. printf ("Container%s has%d object (s) consuming%d bytes\n" $oldcontainer->name, $oldcontainer-&G T;count, $oldcontainer->bytes); Delete the container Delete () method to delete the container $oldcontainer->delete (); Note that container must be empty when it is deleted, which means that there must be no object associated with it. Update container In the background, the container is created and updated in exactly the same way. You can use the Create () method to update container, however, the update () method is also present as an alias to the Create () method because it may be different in semantics (in your program): $oldcontainer- >metadata->update_time = time (); $oldcontainer->update ();
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.