Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3145] Using multipart POST with HTTPClient

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2017-06-07T22:55:37.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterAndre Carregal
AssigneeIngo Muschenetz
Created2011-04-15T03:38:01.000+0000
Updated2017-06-07T22:55:37.000+0000

Description

Currently there is no way to POST multipart messages using HTTPClient. Are there any plans to do so?

Comments

  1. Stephen Tramer 2011-04-15

    Need to discuss how we're going to break up XHR/HTTPClient going forward. Don't want to put multipart features in a single-request architecture.

  2. Andre Carregal 2011-04-15

    Call me naive if you want, but what about keeping full compatibility with the current API by using an optional second parameter for HTTPClient.send? I was thinking in something like:

       HTTPClient.send(data, multipart)
       

    where data would have the current semantics and multipart, if present, would be an Array with multiple file objects and their properties:

       {
          { name :'fieldname',
            filename :'filename',
            filedata :'filedata'
            [, 'Content-Type' : 'content-type']
            [, 'Content-Transfer-Encoding' : 'encoding']
          },
          { ... },
          ...
       }
       

    The presence of multipart would also signal the need for a multipart protocol instead of the default one. In that case the function would change the response preamble accordingly and add a functional boundary string.

    The function could also infer Content-Type for each part using the filename extension, so a full example could be something like:

       var avatardata = avatarfile.read();
       var videodata = videofile.read();
       
       var data = {name : 'a name', option : 'some value'};
       var multipart = {
          { name = 'avatar', filename = 'thumb.jpg',
            filedata =  avatardata,
            Content-Transfer-Encoding' : 'base64' },
          { name = 'video',
            filename = 'presentation.avi',
            filedata = videodata }
       };
       
       HTTPClient.send(data, multipart);
       
  3. Lee Morris 2017-06-07

    Closing ticket due to time passed.

JSON Source