[PHPSDKforOpenStack/RackspaceAPIs] using object storage service Swift is the object storage service of OpenStack. In the php-opencloud Library, The ObjectStore class (OpenS [php sdk for OpenStack/Rackspace APIs] created through the connection object uses the object storage service
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');
With 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 containers in an OSS instance
The ContainerList object is a collection of INER 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 iner
Use the newly created $ swift object's Container () method to create a new (empty) container.
$mycontainer = $swift->Container();
Save the Container to the 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 = 'MyContainerName';$mycontainer->Create();
Retrieve existing INER iner
If you pass a parameter to the objectiner () 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 includes the metadata information of the Container.
printf("Container %s has %d object(s) consuming %d bytes\n", $oldcontainer->name, $oldcontainer->count, $oldcontainer->bytes);
Delete Container
Delete () method to Delete the Container
$oldcontainer->Delete();
Note that the Container must be empty when it is deleted, that is, no object must be associated with it.
Update 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, because this may be different in semantics (in your program ):
$oldcontainer->metadata->update_time = time();$oldcontainer->Update();
From: https://github.com/rackspace/php-opencloud/blob/master/docs/userguide/objectstore.md