pinturic
pinturic

Reputation: 2263

Get openstack public url of an object

I am using openstack to upload an object to a container like explained here: https://docs.openstack.org/openstacksdk/latest//user/guides/object_store.html#uploading-objects

I would like to know if it is possible to programmatically know the public url of the file that I just uploaded.

I am using the python openstack sdk framework but I cannot find a method to have this with any of the endpoints that are available there.

Upvotes: 1

Views: 1930

Answers (4)

Migwell
Migwell

Reputation: 20147

This isn't directly related to programmatic access in Python, but for future google searchers, here are two methods I've found:

Via GUI

Go to Object Store -> Containers in the OpenStack dashboard, then click on your container. If you check "Public Access", then the following link will appear: enter image description here

Via CLI

You have to have python-swiftclient installed and the appropriate credentials configured:

  1. Run swift stat <container>. If the output includes Read ACL: .r:* then it has public access, so you're all good. If not, use swift post --read-acl .r:* <container>
  2. Get the swift base URL using swift auth. It will output something like OS_STORAGE_URL=https://object-store.some.host/v1/AUTH_06d6e708e3e642da99d846ba3ea629c5. This URL is the base URL you will use to calculate the public URL.
  3. The final public URL will be {base}/{container}/{object}, e.g. for an object called object.txt in container container, the URL would be https://object-store.some.host/v1/AUTH_06d6e708e3e642da99d846ba3ea629c5/container/object.txt

Upvotes: 0

Norbert_Cs
Norbert_Cs

Reputation: 136

The endpoint is defined in your openstack and you can list the endpoints with

openstack endpoint list

Upvotes: 0

Norbert_Cs
Norbert_Cs

Reputation: 136

I guess openstack using swift for object store, in that case you can use the swift python client:

https://docs.openstack.org/python-swiftclient/latest/service-api.html

Upvotes: 1

Norbert_Cs
Norbert_Cs

Reputation: 136

The Object Storage API supports the standard, non-serialized response format, which is the default, and both JSON and XML serialized response formats.I you are authorized , you can get it like :

/v1/{account}/{container}/{object}
/v1/12345678912345/my_files/mypicture01.jpg

For example, if the endpoint for Object Storage is objects.mycloud.com, the returned URL is "https://objects.openstackmycloud.com/v1/12345678912345/my_files".

To access a container, append the container name to the resource path.

To access an object, append the container and the object name to the path.

Upvotes: 1

Related Questions