[Php sdk for OpenStack/Rackspace APIs] Using Object Storage Service

Source: Internet
Author: User

Swift is an object storage service of OpenStack. In the php-opencloud library, access the ObjectStore class (OpenStack or Rackspace) created by the connection object. For example, $ cloud = new \ OpenCloud \ OpenStack (array ('username' => '{username}', 'Password' => '{password }')); $ swift = $ cloud-> ObjectStore ('cloudfiles', 'dfw'); using the newly created $ swift, you can use different object storage components. The instance of the highest level object storage component is Container, and Container is the Set Name of the object, which is similar to the directory and folder in the file system (in fact not the same ). All objects are saved in the Container. List all Container ContainerList objects in an object storage instance as a collection of Container objects. List all containers in an OSS instance: $ containers = $ swift-> ContainerList (); while ($ Container = $ containers-> Next ()) printf ("% s \ n", $ container-> name); like other object sets, this also supports the First (), Next (), and Size () methods. Create a new iner 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 OSS instance and use the Create () method: $ mycontainer-> Create ('mycontainername '); name is not required in the Create () method, if the name has been set. It is convenient to specify a name directly in the method. $ Mycontainer-> name = 'myininername'; $ mycontainer-> Create (); search for 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 is retrieved. This includes the metadata information of the Container. Printf ("Container % s has % d object (s) consuming % d bytes \ n", $ oldcontainer-> name, $ oldcontainer-> count, $ oldcontainer-> bytes ); the Delete iner Delete () method deletes Container $ oldcontainer-> Delete (). Note that the Container must be empty when it is deleted, that is, no object must be associated with it. Update the Container in the background. The Container creation and update methods are the same. You can use the Create () method to Update the Container. However, the Update () method is also used as the alias of the Create () method, this may be different in semantics (in your program): $ oldcontainer-> metadata-> update_time = time (); $ oldcontainer-> Update ();

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.