do you have any idea or link resources on how to configure swift to allow cors. Currrently im doing javascript upload function in openstack swift but im getting an error "No Access-Control-Allow-Origin". Thanks
Maybe you are trying to reach a container that you did not append the origin of the page to the container's X-Container-Meta-Access-Control-Allow-Origin header. You can append it to your container using something like this curl:
curl -X POST -H 'X-Auth-Token: xxx' \
-H 'X-Container-Meta-Access-Control-Allow-Origin: http://localhost' \
http://192.168.56.3:8080/v1/AUTH_test/cont1
Here is the full description on this subject on Openstack documentation: http://docs.openstack.org/developer/swift/cors.html
For anyone that went to the official docs and then was stuck with the paramentes for the cURL post.
This are two ways of doing this.
Use pip install python-openstackclient
to get the package and use the ENV vars to authenticate .
Once you can issue a command like openstack container show your-container
, then you can also use set --property
.
Eg
openstack container set --property Access-Control-Allow-Headers='Content-Type, X-CSRFToken' your-container
openstack container set --property Access-Control-Allow-Origin='https://your.domain.com https://other.domain.com' your-container
In order to user curl, you want to post a command like:
curl -i -X POST -H 'X-Auth-Token: <YOUR_TOKEN>' \
-H 'X-Container-Meta-Access-Control-Allow-Origin: https://your.domain.com ' \
<YOUR_STORAGE_URL/your-container>
For this you need to find YOUR_TOKEN and YOUR_STORAGE_URL.
You can use the python-swiftclient ( pip install python-swiftclient
). After authenticating, run
swift stat -v --info
The output will contain both:
StorageURL: YOUR_STORAGE_URL
Auth Token: YOUR_TOKEN
Account: v1
Containers: 99
Objects: 9999
Bytes: 999999
Strict-Transport-Security: max-age=31536000; includeSubdomains
Server: nginx
Connection: keep-alive
X-Timestamp: 1505478377.08455
X-Account-Bytes-Used-Actual: 9999999
X-Trans-Id: tx009999999999a9-999999-9999999-default
Content-Type: text/plain; charset=utf-8
Accept-Ranges: bytes
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.