Phonegap Android Filetransfer Error Code 3

跟風遠走 提交于 2019-12-07 06:15:47

问题


I am working on mobile application for Android, which uses Dave Johnson's Facebook Connect Plugin (https://github.com/davejohnson/phoneg...), Camera and FileTransfer. Basically the user clicks on a button to Take a Photo ( The Phone Camera Starts, the user takes a photo ), then this photo is uploaded to a server. The problem is that first time everything is fine, but when I hit the button again to shoot a second photo, the photo can't be uploaded to a server and the returned error is from FileTransfer - Error Code 3.

I have set options.chunkedMode = false; This doesn't help.

I know that this is a connection error, I whitelisted the domain that I'm uploading the picture to in the /res/xml/cordova.xml file. I searched the web a lot to find a working solution there are other people complaining about this, but there is no working solution provided. I'm using Cordova 1.8.1 ( I also tested with 1.8.0, 1.7.0, 1.6.1, 1.5.0 ). I tested with newer versions of Phonegap for example 1.9.0 but can't build the project - the facebook plugin doesn't work with this version of Phonegap. I am testing using Emulator Android 4.1 (API 16). I tried different things to make it work while I was looking at the logs in details, but I couldn't make it work. I'm trying to find a solution, because it is very important, please help me solve this issue. Thank you in advance for you answers.


回答1:


You can try either of these:

Set android:debuggable="true" in the tag of your AndroidManifest.xml file.

Set instead of just the * as it's recommended in the comments section as follows:

<!-- <access origin="https://example.com" /> allow any secure requests to example.com -->
<!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www -->
<!-- <access origin=".*"/> Allow all domains, suggested development use only -->

From; https://stackoverflow.com/a/12011782/610880




回答2:


This is an unfixed bug in the phonegap library, since there were no bug fixes, i had to get it work by my work around (Basically reupload on every alternate failure):

ft.upload(path,
          encodeURI("http://yourdomain.com/upload.php"),
            function(result) {
                alert("Uploaded");
            },
            function(error) {
        ft.upload(path,
        encodeURI("http://yourdomain.com/upload.php"),
        function(result) {
                alert("Uploaded");                  
        },
        function(error) {
            alert("Error uploading image");
        },
        { fileName: name, fileKey: "file", mimeType: "image/jpeg", chunkedMode: false }, true);     
                },
                { fileName: name, fileKey: "file", mimeType: "image/jpeg", chunkedMode: false }, true);


来源:https://stackoverflow.com/questions/12629135/phonegap-android-filetransfer-error-code-3

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