Created
March 9, 2018 19:42
-
-
Save mihaiserban/acbe3420aa8df62f5bd6b9aba3bba0fb to your computer and use it in GitHub Desktop.
This file contains 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 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