Skip to content

Instantly share code, notes, and snippets.

Avatar
🛌
Working from home

Ahmed Shatat ashatat

🛌
Working from home
View GitHub Profile
@ashatat
ashatat / chunkedMediaTwitter.js
Created Feb 5, 2019
upload media files on twitter api, not working with all videos :(
View chunkedMediaTwitter.js
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) => {