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

357 views Asked by At

I'm using the laravel-rackspace-opencloud package to manage files on RackSpace's cloud files platform. 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.

1

There are 1 answers

0
kamlesh.bar On

Please follow the steps to create / delete file containers

  1. create rack-space file containers with 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();