Pirkka Esko Pirkka Esko - 1 year ago 80
Ruby Question

How to create publicly readable object store containers with ruby openstack gem?

I have tried to create publicly readable openstack object store containers like this:

os = OpenStack::Connection.create(...)
container = os.create_container(container_name)
container.set_metadata({'X-Container-Read' => '.r:*'})

Using my code above, the newly created containers are private.

What is the correct way to create containers with public read permissions with the ruby openstack gem?

Answer Source

You can try the following way.

You can redfine the create_container method


class MyStack < OpenStack::Swift::Connection
  def create_container(containername)
   @connection.req("PUT", path, {:headers=>{"Content-Length"=>"0", "X-Container-Read" => ".r:*", "X-Container-Write" => ".r:*}})
   OpenStack::Swift::Container.new(self, containername)

These "X-Container-Read" => ".r:*", "X-Container-Write" => ".r:*" header value you need to set.


container.set_metadata({"X-Container-Read" => ".r:*", "X-Container-Write" => ".r:*"})
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download