Apache Cordova
  1. Apache Cordova
  2. CB-488

FileTransfer.upload does not follow redirects on Android

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.3.0, 1.4.0, 1.5.0
    • Fix Version/s: Master
    • Component/s: Android
    • Labels:
      None
    • Environment:

      Andoid device: Samsung Galaxy S Plus

      Description

      We are trying to upload a local move file to Youtube though the Youtube API. This API works in such a way that after uploading a file a redirect is done to another location. Unfortunately the Android implementation of FileTransfer does not follow this redirect. (The iPhone implementation does follow the redirect.)

      Steps to reproduce:

      Actual Result:

      • In the success callback the FileUploadResult.responseCode is 302, and the FileUploadResult.response is "Temporarily Moved" (or similar depending on the webserver that responded with the redirect).

      Expected Result:

      • The redirect is followed and the result of the new location is retreived and represented in the FileUploadResult instance.
        Or (but lower preference):
      • The FileUploadResult instance also contains the HTTP headers that were sent with the response so that the Location header (containging the url to redirect to) is known.

        Activity

        Hide
        Simon MacDonald added a comment -

        This is a pretty simple fix. Can you build the PhoneGap source? If so I can tell you that you need to add:

        conn.setInstanceFollowRedirects(true);

        In the upload method. If you can't build the src I can send you a .jar/.js for testing.

        Show
        Simon MacDonald added a comment - This is a pretty simple fix. Can you build the PhoneGap source? If so I can tell you that you need to add: conn.setInstanceFollowRedirects(true); In the upload method. If you can't build the src I can send you a .jar/.js for testing.
        Hide
        Wouter added a comment -

        Great that a solution is found so quickly.

        But no I cannot build the PhoneGap source, so a jar and js would be helpful. I presume this build will be based on the last version of PhoneGap (1.6.0)?

        And will this fix also be included in the next versioin(s) of PhoneGap?

        Thank you!

        Show
        Wouter added a comment - Great that a solution is found so quickly. But no I cannot build the PhoneGap source, so a jar and js would be helpful. I presume this build will be based on the last version of PhoneGap (1.6.0)? And will this fix also be included in the next versioin(s) of PhoneGap? Thank you!
        Hide
        Wouter added a comment -

        From what I understand of the java documentation it looks like the default value of that instanceFollowRedirects is already true, but I am not too familiar with java. Therefor just asking: are you sure this will be the solution?

        Show
        Wouter added a comment - From what I understand of the java documentation it looks like the default value of that instanceFollowRedirects is already true, but I am not too familiar with java. Therefor just asking: are you sure this will be the solution?
        Hide
        Simon MacDonald added a comment -

        No, I'm not sure I will send you a jar/js combo to test via email.

        Show
        Simon MacDonald added a comment - No, I'm not sure I will send you a jar/js combo to test via email.
        Hide
        Wouter added a comment -

        Thank you for the jar and js, but unfortunately these do not resolve this issue...
        I still get the same result: the redirect is not followed.

        Do you have another idea how to solve this issue?

        Show
        Wouter added a comment - Thank you for the jar and js, but unfortunately these do not resolve this issue... I still get the same result: the redirect is not followed. Do you have another idea how to solve this issue?
        Hide
        Simon MacDonald added a comment -

        Not yet. That was the first thing that jumped out at me. Out of
        curiosity is the upload switching from HTTP to HTTPS or vice versa?

        Simon Mac Donald
        http://hi.im/simonmacdonald

        On Fri, Apr 13, 2012 at 10:12 AM, Wouter (Commented) (JIRA)

        Show
        Simon MacDonald added a comment - Not yet. That was the first thing that jumped out at me. Out of curiosity is the upload switching from HTTP to HTTPS or vice versa? Simon Mac Donald http://hi.im/simonmacdonald On Fri, Apr 13, 2012 at 10:12 AM, Wouter (Commented) (JIRA)
        Hide
        Wouter added a comment -

        Ok, I hope another solution is possible...

        And yes, the upload to Youtube is https, the redirect is to http.
        Do you think it will make a difference if the protocols are the same? If so then perhaps we can ttry that (but that will be next week).

        Show
        Wouter added a comment - Ok, I hope another solution is possible... And yes, the upload to Youtube is https, the redirect is to http. Do you think it will make a difference if the protocols are the same? If so then perhaps we can ttry that (but that will be next week).
        Hide
        Wouter added a comment -

        I tried uploading to http and still redirecting to http, so no protocol change. This doe not make a difference: the redirect still is not followed.

        Show
        Wouter added a comment - I tried uploading to http and still redirecting to http, so no protocol change. This doe not make a difference: the redirect still is not followed.
        Hide
        Filip Maj added a comment -

        Updating component to Android. Setting to master as a confirmed issue.

        Show
        Filip Maj added a comment - Updating component to Android. Setting to master as a confirmed issue.
        Hide
        Saurabh added a comment -

        Wild guess :Can url whitelist be the culprit ?

        Show
        Saurabh added a comment - Wild guess :Can url whitelist be the culprit ?
        Hide
        Joe Bowser added a comment -

        What's the status of this issue? It doesn't look like it's been touched in months.

        Show
        Joe Bowser added a comment - What's the status of this issue? It doesn't look like it's been touched in months.
        Hide
        Simon MacDonald added a comment -

        I parked it due to the talk about super-ceding FileTransfer with XHR2.

        Show
        Simon MacDonald added a comment - I parked it due to the talk about super-ceding FileTransfer with XHR2.
        Hide
        Joe Bowser added a comment -

        This probably should belong to you.

        Show
        Joe Bowser added a comment - This probably should belong to you.
        Hide
        Joe Bowser added a comment -

        This bug has gone stale. If this is still broken, please re-open this issue.

        Show
        Joe Bowser added a comment - This bug has gone stale. If this is still broken, please re-open this issue.

          People

          • Assignee:
            Andrew Grieve
            Reporter:
            Wouter
          • Votes:
            5 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development