Created
December 21, 2014 06:40
-
-
Save hash-bang/f897f72fa8048ebb315d to your computer and use it in GitHub Desktop.
Exec() to Request.Post()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var exec = require('child_process').exec; | |
var request = require('request'); | |
exec('echo hello world', function(err, stdout, stderr) { | |
request.post({ | |
method: 'POST', | |
url: 'http://localhost/post/this/somewhere', | |
formData: { | |
myFile: { | |
value: stdout, | |
options: { | |
filename: 'myfile.xml', | |
contentType: 'text/plain' | |
} | |
} | |
} | |
}) | |
.on('response', function(res) { | |
console.log("DONE", res); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment