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 :
http://www.w3.org/TR/2013/CR-cors-20130129/
Basically what happen when in Javascript we do :
request.open("POST", "http://swift/AUTH_account/container/");
request.setRequestHeader('X-Auth-Token', myToken);
request.send();
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 :
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:
http://docs.openstack.org/developer/swift/cors.html
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 :