PHP OpenCloud / OpenStack如何为公共访问创建容器

时间:2017-02-23 21:04:50

标签: php laravel openstack-swift php-opencloud

使用Laravel和OpenCloud / OpenStack,我可以使用createContainer函数创建一个容器,但它默认创建一个私有容器,我想创建一个具有公共读访问权限的容器(可以从托管提供者门户网站完成)

这是我的代码:

$client = app()->make('OpenCloud\OpenStack');    
$service = $client->objectStoreService('swift', $data_center);    
$container = $service->createContainer($container_name);    
// trying to find how to set $container read access ???

1 个答案:

答案 0 :(得分:0)

由于默认情况下swift容器不公开,您可以通过更改容器元数据来更改它。

这可能有效:

$metadata = $container->appendToMetadata(array(
    'X-Container-Read' =>: '.r:*'
));

[1] http://docs.php-opencloud.com/en/latest/services/object-store/containers.html#create-or-update-container-metadata

[2] https://ask.openstack.org/en/question/80609/how-to-make-a-container-public-in-swift-rest-api/