Swift is an object storage service for OpenStack. 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 object storage component instance is Container,container is the collection name of the object, similar to the directory and folder in the file system (not actually equivalent). All objects are saved in the container. Enumerating all container Containerlist objects in an object storage instance is a collection of container objects. Enumerates all container in an object storage instance: $containers = $swift->containerlist (), while ($container = $containers->next ()) printf ("% S\n ", $container->name); Like other object collections, this also supports the first (), Next (), and size () methods. Create a new container using the container () method of the newly created $swift object above 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 is not required in the Create () method, if name is already set. It is also convenient to specify the name directly in the method. $mycontainer->name = ' mycontainername '; $mycontainer->create (); Retrieving existing container If you pass a parameter to the container () method of the ObjectStore object, you can retrieve an existing container: $oldcontainer = $Swift->container (' Someoldcontainer '); In this case, information about Someoldcontainer will be retrieved. This contains the metadata information for the container. printf ("Container%s has%d object (s) consuming%d bytes\n", $oldcontainer->name, $oldcontainer->count, $ oldcontainer->bytes) Delete the container Delete () method to delete the container $oldcontainer->delete (); Note that container must be empty when it is deleted. This means that there must be no object associated with it. Update container in the background, the container is created and updated exactly the same way. You can use the Create () method to update the 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 ();
http://www.bkjia.com/PHPjc/477123.html www.bkjia.com true http://www.bkjia.com/PHPjc/477123.html techarticle Swift is an object storage service for OpenStack. In the Php-opencloud library, the ObjectStore class (OpenStack or Rackspace) created by the Connection object is accessed. For example: $cloud = new \openclou ...