Apache Cordova
  1. Apache Cordova
  2. CB-765

Header support for PhoneGap's FileTransfer (Upload)

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.0
    • Fix Version/s: 1.9.0
    • Component/s: iOS
    • Labels:
      None

      Description

      It would be great to support headers for FileTransfer's iOS version (as done in Android: CB-78).

      Right now, I had redefined CDVFileTranfer for our needs and added just after userAgent definition:

      if(userAgent)

      { [req setValue: userAgent forHTTPHeaderField:@"User-Agent"]; }

      NSMutableDictionary* headers = [params objectForKey:@"headers"];
      NSEnumerator *enumerator = [headers keyEnumerator];
      id key;
      id val;
      NSString *nkey;

      while (nkey = [enumerator nextObject]) {
      val = [headers objectForKey:nkey];
      if(!val || val == [NSNull null])

      { continue; }

      // if it responds to stringValue selector (eg NSNumber) get the NSString
      if ([val respondsToSelector:@selector(stringValue)])

      { val = [val stringValue]; }

      // finally, check whether it is a NSString (for dataUsingEncoding selector below)
      if (![val isKindOfClass:[NSString class]])

      { continue; }

      //if ([key respondsToSelector:@selector(stringValue)])

      { [req setValue:val forHTTPHeaderField:nkey]; //}


      }

      If you can include this code or similar one into future version of Cordova it will be awesome.

      Thanks,

        Issue Links

          Activity

          Aurelien MERCIER created issue -
          Shazron Abdullah made changes -
          Field Original Value New Value
          Link This issue is related to CB-78 [ CB-78 ]
          Shazron Abdullah made changes -
          Fix Version/s 1.9.0 [ 12319551 ]
          Shazron Abdullah made changes -
          Summary Header support for PhoneGap's FileTransfer Header support for PhoneGap's FileTransfer (Upload)
          Herm Wong made changes -
          Assignee Shazron Abdullah [ shazron ] Herm Wong [ hermwong ]
          Herm Wong made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Herm Wong made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Herm Wong made changes -
          Link This issue is related to CB-970 [ CB-970 ]
          Aurelien MERCIER made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Santtu Pajukanta made changes -
          Link This issue is related too CB-1543 [ CB-1543 ]
          Gavin made changes -
          Link This issue is related to CB-1543 [ CB-1543 ]
          Gavin made changes -
          Link This issue is related to CB-1543 [ CB-1543 ]

            People

            • Assignee:
              Herm Wong
              Reporter:
              Aurelien MERCIER
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development