[PHP SDK for Openstack/rackspace APIs] using object storage Services _php Tutorial

Source: Internet
Author: User
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 ...

  • Related Article

    Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.