One of our client at eNovance had a need to be able to upload to Swift directly from a web browser without going via a PHP proxy.
Things in browser-land are not exactly the same as what we have in user-land, it is a bit more restricted to ensure the end-user security and there is a few hoops to jumpÂ through to get it working.
To be able to do a xmlrpc upload to another server (swift in this case) there is a ‘standard/recommendation’ document made by W3C about it located here :
The browser just before the request will send an OPTIONS request to check with the server if the request is allowed by the server. This look like this when uploading to Swift :
The Options request that the browser does is literally asking for the server (swift) to know if this domain where it’s uploading from is allowed to upload directly via xmlrpc. The request looks like this :
It says, hello there: my Origin: is this IP and I want to be able to access with this method ‘PUT’, can I do it ? The server will reply something along (if it’s allowed), yeah sure please feel free to send this headers along and those methods and Origin are actually what I am allowing.
Thanks to the work of Adrian Smith this is supported since Swift version 1.7.5 (and improved in 1.7.6), you can do Â at server level config or with headers on container easily see the full detailled documentation here:
While working on this I could not find a clear example to test it, I only found a great article on this page :
that was targetted to amazon s3 and I adapted it to use with OpenStack Swift.
You can find it here and use it as an example for your application :