简体   繁体   English

如何使用laravel-rackspace-opencloud创建/删除容器?

[英]How do you create / delete containers with laravel-rackspace-opencloud?

I'm using the laravel-rackspace-opencloud package to manage files on RackSpace's cloud files platform. 我正在使用laravel-rackspace-opencloud软件包来管理RackSpace的云文件平台上的文件。 Is it possible to use this library to create / delete file containers? 是否可以使用此库创建/删除文件容器? I've not been able to find an example of this, and the README only seems to reference the management of files within containers that have already been created. 我找不到这样的示例,自述文件似乎仅引用已创建容器中文件的管理。

Please follow the steps to create / delete file containers 请按照以下步骤创建/删除文件容器

  1. create rack-space file containers with laravel 使用laravel创建机架空间文件容器

     $client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array( 'username' => 'XXXXXX','apiKey' => 'XXXXXX')); try{ $ContainerName = 'todo'; // static for now $objectStoreService = $client->objectStoreService(null, 'DFW'); $container = $objectStoreService->createContainer($ContainerName); } catch (Guzzle\\Http\\Exception\\ClientErrorResponseException $e) { Log::info($e->getResponse()); } 
  1. Delete Containers 删除容器
  //1. conneciton
  $client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(   
           'username' => 'XXXXXX','apiKey'   => 'XXXXXX'));

  // 2. get region
  $objectStoreService = $client->objectStoreService(null, 'DFW');

  // 3. Get container.
  $container = $objectStoreService->getContainer('{containerName}');
  // 4. Delete container.
  $container->delete();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM