Skip to content

Instantly share code, notes, and snippets.

View ashatat's full-sized avatar
🈴
Working from home

Ahmed Shatat ashatat

🈴
Working from home
View GitHub Profile
@ashatat
ashatat / chunkedMediaTwitter.js
Created February 5, 2019 19:21
upload media files on twitter api, not working with all videos :(
const client = new Twitter({
consumer_key: process.env.TWITTER_CONSUMER_KEY,
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
access_token_key: process.env.oauthAccessToken,
access_token_secret: process.env.oauthAccessSecret,
});
// after uploading the file and store it on the server using multer the path will be in (file.path)
const streamFile = fs.createReadStream(file.path, { highWaterMark: 128 * 1024 });
function makePost(endpoint, params, counter) {
return new Promise((resolve, reject) => {