-1

Note that I'm trying to upload from the meteor/node server. I'm trying to interface with EchoSign REST API. To do this I have to upload a pdf from my server to theirs using multipart POST. I've already figured out how to do a normal POST to a server using just node.

If possible, I'd like to do this without using any extra modules besides the standard node modules like fs & http.

Here's my code so far:

var http = require('http');

options = {
  host: 'localhost',
  port:8080,
  path: '/upload',
  method: 'POST',
};

var callback = function(response) {
  response.setEncoding('utf-8');
  var responseString = '';
  response.on('data', function(data) {
    responseString += data;
  });
  response.on('end', function() {
    console.log(responseString);
  });
}

var request = http.request(options, callback);
request.on('error', function(e) {
  console.log('There was an error: '+e);
});
request.end();

Can anyone point me in the right direction?

Jared Martin
  • 653
  • 7
  • 20
  • Related? http://stackoverflow.com/questions/13797670/nodejs-post-request-multipart-form-data – Paul Apr 28 '15 at 19:58
  • Well, I was hoping to do it without using extra modules, but Ill give that a try. – Jared Martin Apr 28 '15 at 21:34
  • possible duplicate of [Generating HTTP multipart body for file upload in JavaScript](http://stackoverflow.com/questions/25455475/generating-http-multipart-body-for-file-upload-in-javascript) – Christian Fritz Apr 28 '15 at 21:58

1 Answers1

0

Well, in the end, I wasn't able to generate the multipart body successfully, so I used the restler package instead. It handles all that difficult stuff for you, however, I think this should be included in the Meteor.call() function.

Jared Martin
  • 653
  • 7
  • 20