Code 3 Upload Error on Android 4.3 when uploading to S3

10 posts, 0 answers
  1. Idan
    Idan avatar
    76 posts
    Member since:
    Oct 2012

    Posted 17 Mar 2014 Link to this post

    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.

  2. Borislav
    Admin
    Borislav avatar
    35 posts

    Posted 18 Mar 2014 Link to this post

    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!
  3. Idan
    Idan avatar
    76 posts
    Member since:
    Oct 2012

    Posted 18 Mar 2014 in reply to Borislav Link to this post

    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.
  4. Idan
    Idan avatar
    76 posts
    Member since:
    Oct 2012

    Posted 19 Mar 2014 in reply to Borislav Link to this post

    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.
  5. Ajay
    Ajay avatar
    4 posts
    Member since:
    Mar 2014

    Posted 20 Mar 2014 in reply to Idan Link to this post

    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
  6. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 21 Mar 2014 Link to this post

    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.

     
  7. Robert
    Robert avatar
    2 posts
    Member since:
    Nov 2013

    Posted 11 Apr 2014 in reply to Borislav Link to this post

    I have tried removing the Header and I'm still getting an Error Code 3. Is there any solution on how to test FileTransfer.
  8. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 16 Apr 2014 Link to this post

    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!

     
  9. sprotte55
    sprotte55 avatar
    1 posts
    Member since:
    Jun 2014

    Posted 02 Jul 2014 Link to this post

    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.
  10. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 07 Jul 2014 Link to this post

    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!

     
Back to Top