【发布时间】:2014-10-23 10:59:22
【问题描述】:
我正在使用laravel-rackspace-opencloud 包来管理 RackSpace 的云文件平台上的文件。是否可以使用这个库来创建/删除文件容器?我找不到这样的例子,自述文件似乎只引用了已经创建的容器中文件的管理。
【问题讨论】:
标签: laravel-4 rackspace-cloudfiles php-opencloud
我正在使用laravel-rackspace-opencloud 包来管理 RackSpace 的云文件平台上的文件。是否可以使用这个库来创建/删除文件容器?我找不到这样的例子,自述文件似乎只引用了已经创建的容器中文件的管理。
【问题讨论】:
标签: laravel-4 rackspace-cloudfiles php-opencloud
请按照步骤创建/删除文件容器
使用 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. 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();
【讨论】: