Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-765

Header support for PhoneGap's FileTransfer (Upload)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.0
    • 1.9.0
    • cordova-ios
    • 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,

      Attachments

        Issue Links

          Activity

            People

              hermwong Herm Wong
              quanta 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