Skip to content

Instantly share code, notes, and snippets.

@mishitpatel
Created July 21, 2017 05:22
Show Gist options
  • Select an option

  • Save mishitpatel/bb30ae48e9e21b92c6dc2e12abb40e81 to your computer and use it in GitHub Desktop.

Select an option

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
//
// 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