Skip to content

Instantly share code, notes, and snippets.

@mihaiserban
Created March 9, 2018 19:42
Show Gist options
  • Save mihaiserban/acbe3420aa8df62f5bd6b9aba3bba0fb to your computer and use it in GitHub Desktop.
Save mihaiserban/acbe3420aa8df62f5bd6b9aba3bba0fb to your computer and use it in GitHub Desktop.
var request = require('request');
const MEDIA_URL = 'https://api.linkedin.com/media/upload'
function postMedia(token, filename, mediaType, mediaData) {
console.log(token)
return new Promise((resolve, reject) => {
var formData = {
custom_file: {
value: new Buffer(mediaData),
options: {
filename: filename,
contentType: mediaType
}
}
};
request.post({url: MEDIA_URL, formData: formData}, function optionalCallback(err, httpResponse, body) {
if (err) {
return reject(err);
}
return resolve(body);
}).auth(null, null, true, token);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment