【问题标题】:How do you create / delete containers with laravel-rackspace-opencloud?如何使用 laravel-rackspace-opencloud 创建/删除容器?
【发布时间】:2014-10-23 10:59:22
【问题描述】:

我正在使用laravel-rackspace-opencloud 包来管理 RackSpace 的云文件平台上的文件。是否可以使用这个库来创建/删除文件容器?我找不到这样的例子,自述文件似乎只引用了已经创建的容器中文件的管理。

【问题讨论】:

    标签: laravel-4 rackspace-cloudfiles php-opencloud


    【解决方案1】:

    请按照步骤创建/删除文件容器

    1. 使用 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. 删除容器
      //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();
    

    【讨论】:

      猜你喜欢
      • 2013-02-23
      • 1970-01-01
      • 1970-01-01
      • 2016-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多