PHP OpenCloud/OpenStack how to create container for public access

800 Views Asked by At

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

There are 1 best solutions below

1
Nelson Marcos On

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/