简体   繁体   中英

PHP OpenCloud/OpenStack how to create container for public access

Using Laravel with OpenCloud/OpenStack, I can create a container using the createContainer function but it creates a private container by default and I would like to create a container with public read access (which can be done from the hosting provider portal).

Here is my code:

$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 ???

Since by default swift container are not public, you can change that by changing the container metadata.

This might work:

$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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM