Skip to content

Instantly share code, notes, and snippets.

@simong
Created August 3, 2015 23:30
Show Gist options
  • Save simong/ea7dfcfb9aa6063a6884 to your computer and use it in GitHub Desktop.
Save simong/ea7dfcfb9aa6063a6884 to your computer and use it in GitHub Desktop.
var opts = {
'url': someUrl,
'method': 'POST'
};
var r = request(opts, function(err, response, body) {
if (err) {
return callback(err);
}
return callback(null, response.headers.location);
});
// Add some parameters
var form = r.form();
// Append a few basic parameters (these values are all strings or numbers)
_.each(uploadInfo.upload_params, function(value, key) {
form.append(key, value);
});
// Append a file
form.append('file', fs.createReadStream(filePath));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment