Phonegap : FileTransfer.upload() fails on Android

谁说胖子不能爱 提交于 2019-12-28 18:40:29

问题


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.


回答1:


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;



回答2:


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.



来源:https://stackoverflow.com/questions/8522729/phonegap-filetransfer-upload-fails-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!