This is a migrated thread and some comments may be shown as answers.

Code 3 Upload Error on Android 4.3 when uploading to S3

9 Answers 278 Views
Apache Cordova
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Idan
Top achievements
Rank 1
Idan asked on 17 Mar 2014, 10:59 AM
Hi,

I am getting a "Code 3" error when uploading an image file from my Cordova 3.2 app to Amazon S3 using FileTransfer. 

The upload options:

options.fileKey = "file";
        options.fileName = filename_for_s3;
        options.mimeType = "image/jpeg";
        options.chunkedMode = false;
        options.headers = {
            Connection: "close"
        }


ft.upload(imageURI, "https://" + data.Bucket + ".s3.amazonaws.com/", successFunc, failFunc, options);


The upload is successful on iPhone and on various older Android versions, except Android 4.3. On Android 4.3 I get this error.  The "Code 3" is a connection error, and because it's related to the version of the operating system, I have no idea how to solve this.

I've search the web and I've read that I am not the only one who encountered this issue, but still not solution for this problem.

I am writing this here that hopefully someone was able to solve it. I spent a week trying to solve this without any success.

Thanks in advance.

9 Answers, 1 is accepted

Sort by
0
Borislav
Telerik team
answered on 18 Mar 2014, 09:51 AM
Hello Idan,

We had a similar bug in our Simulator. It was caused by "Connection: close" header. The bug in your case is probably Cordova related and we hope they will fix it soon.

As a temporary workaround you could try to remove this Connection header.
Or you could try to use the newer version of FileTransfer Cordova plugin. You can get a newer version from Cordova Plugin Registry. The id of the plugin is "org.apache.cordova.file-transfer". After getting the newer version of the plugin you should first disable the old one from project properties. Then import the new one into the project as described here.

Please let us know if any of the proposed workaround works for you.

Regards,
Borislav
Telerik
 
Icenium is now Telerik AppBuilder, and is part of the Telerik Platform. Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!
0
Idan
Top achievements
Rank 1
answered on 18 Mar 2014, 12:59 PM
Thanks a lot for replying.  I will certainly try that now and I will write here when I finish testing. it -- again, thanks for helping me out on this.
0
Idan
Top achievements
Rank 1
answered on 19 Mar 2014, 04:53 PM
Hi,

I was able to update the FileTransfer, File and Media-Capture plugins for the latest version and thy compiled.

I still experience Code 3 error, now even on iOS7 in my iPhone 5S.

Do you have any other suggestions. I also tried removing the "close" in the connection header and it didn't help either.

thanks.
0
Ajay
Top achievements
Rank 1
answered on 20 Mar 2014, 08:32 AM
Hello Idan,
can you share a code snippet to upload images for s3 buckets. am trying the same thing from past 2 days.

Thanks,
Ajay
0
Kaloyan
Telerik team
answered on 21 Mar 2014, 09:47 AM
Hi,

Ajay, here is a good example of how this can be achieved. There is also a complete project on the matter. Please let us know if there are any further issues.

Idan, unfortunately the only solution I can think of and I am capable to find on the net is the using of both the:
options.chunkedMode = false;
options.headers = {
    Connection: "close"
}
Nevertheless, we will continue researching the matter and if we find a solution we will contact you straight away. Until then, you can also check the above mentioned article and see if there is something that could help you out. Another option could be to contact Amazon with the weird behavior. It is possible for them to have a solution about it.

Thank you for the understanding.

Regards,
Kaloyan
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET. Seats are limited.

 
0
Robert
Top achievements
Rank 1
answered on 11 Apr 2014, 05:13 PM
I have tried removing the Header and I'm still getting an Error Code 3. Is there any solution on how to test FileTransfer.
0
Kaloyan
Telerik team
answered on 16 Apr 2014, 01:55 PM
Hello Robert,

Unfortunately, the issue is still relevant. Here is Idan's post on StackOverflow.

One last thing you can try, if your project is targeting Cordova 3.2 is to change this to something prior (e.g. Cordova 3.0). However, I am not sure if this will help but still it's worth trying. For more information about changing the Cordova version of your project, check this article.

Please, let me know if this has any effect.

Regards,
Kaloyan
Telerik
 

Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

 
0
sprotte55
Top achievements
Rank 1
answered on 03 Jul 2014, 02:16 AM
I am using Cordova 3.2 I am having the same issue.
This is my function:
 function uploadPhoto(imageURI) {
            var options = new FileUploadOptions();
            options.fileKey="file";
            options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
            options.mimeType="image/jpeg";
            options.chunkedMode = false;
            var params = {};
                        params.fullpath =imageURI;
                        params.name = options.fileName;
            var ft = new FileTransfer();
            ft.upload(imageURI, document.getElementById('eingabe').value+"/upload_jpg.php", win, fail, options);
        }

It just does not upload the image and I get error code 3.
I have tried Cordova 3.5 but then my download functions dont work anymore.
0
Zdravko
Telerik team
answered on 07 Jul 2014, 08:18 AM
Hello,

It seems that your code is correct except the fact that you might want to encode your server URL and add your params variable to options parameter.

The error you are getting is a connection error. That is why I wonder where do you execute your app? On an actual device or in some of the Simulators? Some details would be helpful.

In order to investigate your issue further we will need your project name if created via Windows or in-browser clients or the project itself if created via our VS extension. Please open a private ticket as described here and attach there the required information.

In the meantime you can debug your code as described here and track your request using Fiddler, even though I doubt you have any requests fired since you receive this error type.

Regarding the download function issue in Cordova 3.5, I want to say that there are some breaking changes introduced in File plugin above version 1.0.0 which Cordova 3.5 app is using. 
Thanks.


Regards,
Zdravko
Telerik
 

Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

 
Tags
Apache Cordova
Asked by
Idan
Top achievements
Rank 1
Answers by
Borislav
Telerik team
Idan
Top achievements
Rank 1
Ajay
Top achievements
Rank 1
Kaloyan
Telerik team
Robert
Top achievements
Rank 1
sprotte55
Top achievements
Rank 1
Zdravko
Telerik team
Share this question
or