Reputation: 2263
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
Reputation: 20147
This isn't directly related to programmatic access in Python, but for future google searchers, here are two methods I've found:
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:
You have to have python-swiftclient
installed and the appropriate credentials configured:
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>
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.{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
Reputation: 136
The endpoint is defined in your openstack and you can list the endpoints with
openstack endpoint list
Upvotes: 0
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
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