Skip to content

Instantly share code, notes, and snippets.

@stormoz
Last active March 8, 2019 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stormoz/93eaa11b846ae413eaf374482842a72d to your computer and use it in GitHub Desktop.
Save stormoz/93eaa11b846ae413eaf374482842a72d to your computer and use it in GitHub Desktop.
Node JS: send binary file as multiform data
var formData = {
'myfile_key': {
value: <Buffer object>
options: {
filename: 'image_file'
}
}
};
const options = {
uri: url,
formData: formData,
method: 'POST'
}
request(options, (err, response, body) => {
console.log('Request complete');
if (err) console.log('Request err: ', err);
console.log(body)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment