title: how to convert multipart/form-data to multipart/mixed
body: <p>The document insert REST api (POST /v1/documents) requires multipart/mixed for content-type. All the examples online show how to use multipart/form-data. Based on my research I learned that multipart/mixed needs to be embedded in multipart/form-data. Can someone please point me to a example or resource where I can get a clue ? Thank you!</p>
  
  <p>fyi: I'm using AngularJS on the front end and Node.js on the backend</p>
  
  <p><strong>Angular code:</strong></p>
  
  <pre><code>         $http({
                  url: '/new',
                  method: 'POST',
                  headers: {
                      'Content-Type': undefined
                  },
                  transformRequest: function(data, getHeaders) {
                      var form = new FormData();
                      form.append('bug', angular.toJson(bug));
                      for (var i = 0; i &lt; data.files.length; i++) {
                          console.log('FORM',data.files[i]);
                          form.append('file' + i, data.files[i]);
                      }
                      return form;
                  },
                  data: {
                      bug: bug,
                      files: $scope.files
                  }
              }).success(function(data, status, headers, config) {
                  Flash.addAlert('success', 'successssss');
              }).error(function(data, status, headers, config) {
                  Flash.addAlert('danger', 'failed');
              });
  </code></pre>
  
  <p><strong>Node code:</strong>: using <a href="https://github.com/mikeal/request" rel="nofollow">request</a>
  NOTE: this code is certainly wrong since it taking data as json instead of mulitpart/mixed which I dont know and hence the question</p>
  
  <pre><code>....
  ....      
  case 'POST':
              console.log('its a POST');
               var url = 'http://api-server.com:8003/v1/documents?extension=json';
              var options = {
                  method: 'POST',
                  headers: req.headers,
                  url: url,
                  body: JSON.parse(req.body.bug),
                  json: true
              };
  
              req.pipe(request(options, function(error, response, body) {
                  if (error) {
                      next(error);
                  }
              })).pipe(res);
  </code></pre>
  
  <p>Here's the multipart/form-data that I get currently</p>
  
  <pre><code>------WebKitFormBoundaryJlYMd1KVllv1WgDS
  Content-Disposition: form-data; name="bug"
  
  {"relatedTo":[],"tickets":[],"id":1,"kind":"Other","createdAt":"2014-09-06T08:33:43.614Z","modifiedAt":"2014-09-06T08:33:43.614Z","status":"Verify","title":"Quae inventore beatae tempora mollit deserunt voluptatum odit adipisci consequat Est dolore quia perspiciatis","submittedBy":{"name":"Sudhakar Reddy","email":"sreddy@mycompany.com","username":"sreddy"},"assignTo":{"name":"Guzman Wagner","email":"guzmanwagner@mycompany.com","username":"small"},"description":"sdsdsdsds","category":"MLOS","tofixin":"Help-1.1","severity":"Performance","priority":{"level":"4","title":"Important"},"relation":"Test Specification task for","clones":[],"version":"6.0-3","platform":"EC2","memory":"Reprehenderit quia aut voluptatem in ex dolore eu numquam eum et esse officia id consequatur Est","processors":"Reiciendis nostrum adipisicing occaecat inventore veniam excepturi","note":"Officiis qui adipisci commodo eveniet, esse aperiam est non unde possimus, sed nesciunt, exercitation eius magna consequat. Sint ipsa, laboriosam.","changeHistory":[],"subscribers":[{"name":"Sudhakar Reddy","email":"sreddy@mycompany.com","username":"sreddy"},{"name":"Guzman Wagner","email":"guzmanwagner@mycompany.com","username":"small"}],"attachments":[{"webkitRelativePath":"","lastModifiedDate":"2014-07-18T23:53:29.000Z","name":"jamesbond.jpg","type":"image/jpeg","size":858159}]}
  ------WebKitFormBoundaryJlYMd1KVllv1WgDS
  Content-Disposition: form-data; name="file0"; filename="jamesbond.jpg"
  Content-Type: image/jpeg
  
  
  ------WebKitFormBoundaryJlYMd1KVllv1WgDS--
  </code></pre>