Created
April 5, 2016 01:43
-
-
Save spasiu/b951ffef634a77ad9f2f474cfacd4196 to your computer and use it in GitHub Desktop.
upload image to smooch via rest api
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 Smooch = require('smooch-core'); | |
| var request = require('request'); | |
| var jwt = require('jsonwebtoken'); | |
| var fs = require('fs'); | |
| var USER_ID = 'a_user_id'; | |
| var KEY_ID = 'your_key_id'; | |
| var SECRET = 'your_secret'; | |
| var token = jwt.sign({ | |
| scope: 'app' | |
| }, | |
| SECRET, | |
| { | |
| headers: { | |
| kid: KEY_ID | |
| } | |
| }); | |
| request.post({ | |
| url: 'http://localhost:8091/v1/appusers/' + USER_ID + '/conversation/images', | |
| formData: { | |
| role: 'appMaker', | |
| text: 'hola!', | |
| source: fs.createReadStream('./tea.jpg') | |
| }, | |
| headers: { | |
| 'authorization': 'Bearer ' + token | |
| } | |
| }, function(err, res, body) { | |
| console.log(err, body); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment