-
-
Save andyyou/dbe4d93d816f51d41e3d44596770c6ba to your computer and use it in GitHub Desktop.
Node.js file upload on Stamplay
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
'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