5

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.

mmsv
  • 51
  • 1
  • 2

2 Answers2

0

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

Community
  • 1
  • 1
Braunson
  • 717
  • 2
  • 12
  • 36
  • 3
    Thank you Braunson for your quick answer, but your advice didn't helped. My conclusion is that if something was wrong either in the config files or in source code it wouldn't upload successfully the first time. The strange thing is that with one algorithm the first time everything is OK, but on the second click FileTransfer gives the error with the exact same algorithm. Please suggest another approach to the problem, this is not a working solution. – mmsv Sep 27 '12 at 21:29
0

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);
rand_mem_RAM
  • 586
  • 5
  • 6