Skip to content

Instantly share code, notes, and snippets.

@andyyou
Forked from claudiopetrini/node_upload.js
Created April 15, 2016 00:23
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 andyyou/dbe4d93d816f51d41e3d44596770c6ba to your computer and use it in GitHub Desktop.
Save andyyou/dbe4d93d816f51d41e3d44596770c6ba to your computer and use it in GitHub Desktop.
Node.js file upload on Stamplay
'use strict';
const request = require('request');
const fs = require('fs');
var formData = {
image: fs.createReadStream(__dirname + '/claudio.jpg'),
};
request.post({
url: 'https://appId.stamplayapp.com/api/cobject/v1/myobject',
formData: formData
}, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
if (httpResponse.statusCode != 200) {
return console.error('upload failed', body)
}
console.log('Upload successful! Server responded with:', body);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment