Works in Mikrob which is deployed both to Titanium Desktop and as a Chrome Application.
This code was extracted from my own code and a wrapper library which I'm working on.
Any questions? Post them in comments.
Here's where everything happens:
-
jsOAuth goes through your post data and checks whether a reference to a file was included source
-
if it finds one, it resets the conent-type source
-
and build the whole form data object for you source
Few things to keep in mind:
-
I used it only with an API which doesn't use OAuth-echo, and allows direct uploads
-
this is based on OAuth 1.0a (Oauth2 is not supported yet)
I tried to make this work with OAuth Echo for TwitPic with no luck.
When I attempted to upload a photo I'd get 401 Unauthorized. After looking at the actual post data I didn't see any of the oauth variables posted. I believe this is what was causing TwitPic to reject it.
(This was tested using the BlackBerry WebWorks SDK on the PlayBook: https://github.com/blackberry/WebWorks/wiki )