Created
July 21, 2017 05:22
-
-
Save mishitpatel/bb30ae48e9e21b92c6dc2e12abb40e81 to your computer and use it in GitHub Desktop.
Sample Node.js request to upload user's profile picture using Sequr's Upload Avatar 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
| // | |
| // Sample Node.js gist to upload the property user's profile picture | |
| // using upload Avatar API | |
| // | |
| var fs = require("fs"); | |
| var request = require("request"); | |
| var options = { | |
| method: 'PUT', | |
| url: 'https://api.sequr.io/v1/property_user/<property_user_id>/avatar', | |
| headers: { | |
| authorization: 'Bearer <API_TOKEN>', | |
| 'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' | |
| }, | |
| formData: { | |
| avatar: { | |
| value: fs.createReadStream("/Users/Becca.jpg"), | |
| options: { | |
| filename: 'Becca.jpg' | |
| } | |
| } | |
| } | |
| }; | |
| request(options, function(error, response, body) { | |
| if (error) { | |
| throw new Error(error); | |
| } | |
| console.log(body); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment