Oh my crap. I swear this was not documented when I worked on the original File Transfer code for Android. The entire FileTransfer plugin can be re-written now to use actual tested code. The only thing we need do is to keep the old method signatures.
If you are looking for me I'll be over in the corner kicking the cat. Simon Mac Donald http://hi.im/simonmacdonald On Wed, Dec 5, 2012 at 9:49 PM, Brian M Dube <bd...@apache.org> wrote: > On 10/30/2012 07:53 AM, Simon MacDonald wrote: > > I would have loved to have used the Apache HttpClient package but we are > > trying to stay away from external dependencies. > > Apache HttpClient is available to applications as part of the Android > platform, isn't it? Perhaps I've misunderstood. > > org.apache.cordova.HttpHandler [1] makes use of HttpClient, but > HttpHandler itself doesn't appear to be referenced by any other Cordova > code. > > I'd be happy to work on a pull request if it is in fact available > without adding a dependency. > > -Brian > > [1] > > https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=blob;f=framework/src/org/apache/cordova/HttpHandler.java > > > When you set chunkedMode to false I know that the transfer worked as per > > your comment on JIRA. I will update the docs to mention Nginx servers. > > > > Simon Mac Donald > > http://hi.im/simonmacdonald > > > > > > On Mon, Oct 29, 2012 at 2:56 PM, Ronald Partridge > > <r...@ronald-douglas.com>wrote: > > > >> See: > >> > >> > https://github.com/apache/incubator-cordova-android/blob/master/framework/src/org/apache/cordova/FileTransfer.java > >> private void upload(final String source, final String target, JSONArray > >> args > >> , CallbackContext callbackContext) > >> > >> Cordova Android may have a bug with the way files are being sent. The > >> Android source code appears to use the built in java HttpURLConnection > and > >> the developer who wrote the functionality decided to write the logic to > >> assemble the post data to be transfered. I examined two different post > >> dumps > >> being sent to a web server running Nginx and Varnish. Notice how the > >> headers are different between *iOS *and *Android*. > >> I would suggest using > >> > >> > http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html > >> > >> Here are the two post dumps: > >> * > >> Android:* > >> > >> POST /service/claim/photo/75?api_key=123ab > >> c HTTP/1.1 > >> Connection: Keep-Alive > >> Content-Type: multipart/form-data;boundary=***** > >> User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.1.1; Nexus S Build/JRO03E) > >> Host: sit.service.app.mydomain.ca > >> Accept-Encoding: gzip > >> Transfer-Encoding: chunked > >> > >> o<EF><8A>P9)^B^@6^@^@^@6^@^@^@^@^@^L^G<AC><C8>^@PV<8E>^A^@E^@^@(<E1>e@ > >> ^@@^F<DE>ESC^_[&c<88><B2>^@P<FF><BD>%&<9C><A5><AF>WĘP^P^Y > >> <E6>^^@^@o<EF><8A>P<93>,^B^@<D9>^D^@ > >> ^@<D9>^D^@^@^@^@^L^G<AC><C8>^@PV<8E>^A^@E^@^D<CB><E1>f@^@@^ > >> F<DA>:<AC>ESC^_[&c<88><B2>^@P<FF><BD>%&<9C><A5><AF>WĘP^X^Y > ^?I^@^@HTTP/1.1 > >> 503 Service Unavailable > >> Server: Varnish > >> Content-Type: text/html; charset=utf-8 > >> Content-Length: 932 > >> Accept-Ranges: bytes > >> Date: Fri, 26 Oct 2012 20:15:43 GMT > >> X-Varnish: 409357173 > >> Age: 0 > >> Via: 1.1 varnish > >> Connection: close > >> X-Cache: MISS > >> > >> > >> *iOS*: > >> > >> POST /service/claim/photo/73?api_key=123abc HTTP/1.1 > >> > >> Host: sit.service.app.mydomain.ca > >> User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) > >> AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206 > >> Content-Length: 139038 > >> Accept: */* > >> Content-Type: multipart/form-data; boundary=*****org.apache. > >> cordova.formBoundary > >> X-Requested-With: XMLHttpRequest > >> > >> Accept-Language: en-us > >> Accept-Encoding: gzip, deflate > >> Connection: keep-alive > >> > >> 4<EF><8A>P;^F^A^@6^@^@^@6^@^@^@^@^@^L^G<AC><C8>^@PV<8E>^A^@E^@^@(}1@ > >> ^@@^FC^S<AC>ESC^_[&c<88><B2>^@P<F7><8F><A1><F9><EB><CF>^^^_<C1>P^P^Y > >> ^X`^@^@4<EF><8A>P<F7>^K^A^@ > >> <9A>^E^@^@<9A>^E^@^@^@PV<8E>^A:^@^U<FA>~<E0>^Z^H^@E^@^E<8C><D7>C@ > >> ^@)^F<FA><9C>&c<88><B2><AC>ESC^_[<F7><8F>^@P^^^_<C1>< > >> > >> > A1><F9><EB><CF>P^P<FF><FF><F9><A6>^@^@--*****org.apache.cordova.formBoundary > >> Content-Disposition: form-data; name="description" > >> > >> Photo > >> --*****org.apache.cordova.formBoundary > >> Content-Disposition: form-data; name="userfile"; > >> filename="cdv_photo_002.jpg" > >> Content-Type: image/jpeg > >> Content-Length: 138722 > >> > >> > >> > >> < > >> > http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/DefaultHttpClient.html > >>> > >> > > >