我正在使用laravel-rackspace-opencloud包来管理RackSpace的云文件平台上的文件。是否可以使用此库来创建/删除文件容器?我无法找到这样的例子,README似乎只引用了已经创建的容器内的文件管理。
答案 0 :(得分: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. 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();