Trying to upload files to another server

I’m trying to work with adobe’s echosign REST API. The idea is I make a PDF, upload it to Echosign, and they get everyone’s signatures. I’m having trouble uploading the pdf to their server.
I’ve figured out how to do http POST requests, but I can’t find info about doing multipart uploads from meteor/node. Most instructions you find when you google are for CollectionFS type of thing, not what I’m looking for.

Right now I have something like this (for now I wrote for plain node.js):

var https = require('https');

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 = https.request(options, callback);
request.on('error', function(e) {
  console.log('There was an error: '+e);
});
request.end();
1 Like

I guess you could use core Node.js readableStream or bufferStream - something that can pipe to response or request

I have not implemented file upload capabilities in my application, but will eventually, so this topic is going to become important to me.

Do we need raw node.js for file uploads to either a local directory or something like S3?

Doesn’t Meteor already provide for http request that handle this scenario?

Meteor HTTP:
http://docs.meteor.com/#/full/http

No, Meteor’s implementation of HTTP on the server is mostly for JSONP requests. You could try to handle multipart/encoded uplodaing with Meteor’s HTTP but it seems real trouble. I think it is better to use connect or express with streams/buffers. And you should be shure that your request endpoint is supported multipart/encoded transfer too.
I just realized Meteor server side multipart/encoded response lib to send heavy images to the client. I can share it if could be helpfull.