Closed vsnthdev closed 3 years ago
Hi @vasanthdeveloper :wave: Thanks for creating this issue.
The mediaUpload
endpoint expects the media
to be base64
encoded.
So - without having tried your reproduction example yet - could you first try to do the following:
const fs = require('fs/promises')
const res = await twitter.media.mediaUpload({
media: await fs.readFile('./image.png', { encoding: 'base64' }) // <- add base64 here
})
console.log('res ', res)
I have a feeling that will work. Thank you.
@SimonHoiberg Yup! that works 🥳 you're a genius! 🙌
@SimonHoiberg It would be great if you make an example of chunked upload since that's tricky 🙂
Couldn't make chunked upload work due to auth failures => https://github.com/FeedHive/twitter-api-client/issues/63
Describe the bug
Below are the authentication requirements by Twitter for
twitter.tweets.statusesUpdate()
andtwitter.media.mediaUpload()
endpoints respectively 👇and
As they require same level of authentication if
twitter.tweets.statusesUpdate()
works thentwitter.media.mediaUpload()
should also work. Wheretwitter.tweets.statusesUpdate()
works as expected,twitter.media.mediaUpload()
responds with a401
. Here's the code I've used 👇And here's the response I get 👇
To reproduce
Steps to reproduce the behavior:
twitter-api-client
as dependency.index.js
const res = await twitter.media.mediaUpload({ media: await fs.readFile('./image.png') })
console.log('res ', res)