Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap : FileTransfer.upload() fails on Android

I'm currently trying to upload a picture to a server with the FileTransfer.upload() method of PhoneGap. It works fine on the iPhone Simulator over Wifi, but fails on an Android phone over 3G or Wifi.

alert(error.code) returns '3' but I couldnt find out what this error code is.

Did anybody stumbled upon the same problem and managed to solve it ? Please help.

like image 971
Titouan de Bailleul Avatar asked Dec 15 '11 15:12

Titouan de Bailleul


2 Answers

Today, I tried Simon MacDonald's answer and it worked, so for those who have the same problem. It's certificate related and can be solved simply by adding a 'true' parameter at the end of the upload() function like below :

upload(filePath, server, successCallback, errorCallback, options, true);

Thank you !

PS: That extra "true" at the end tells upload to accept self signed certs.

like image 41
Titouan de Bailleul Avatar answered Sep 21 '22 07:09

Titouan de Bailleul


Error code 3 is a connection error. Recently we made chunked mode the default for uploading on Android. Try setting your options object to have a chunked mode that is false.

var options = FileUploadOptions();
options.chunkedMode = false;
like image 73
Simon MacDonald Avatar answered Sep 20 '22 07:09

Simon MacDonald