desmondmorris / node-twitter

Client library for the Twitter REST and Streaming API's.
https://www.npmjs.com/package/twitter
MIT License
1.27k stars 237 forks source link

Set the “Content-Transfer-Encoding: base64” header on base64 encoded images #292

Open seanpoulter opened 6 years ago

seanpoulter commented 6 years ago

As a developer, I'd like to POST base64 encoded images but we* get an error. By "we" I mean, this dev: https://stackoverflow.com/questions/50261958

From the Twitter docs on Media Best Practices it says:

When posting base64 encoded images, be sure to set the “Content-Transfer-Encoding: base64” on the image part of the message.

That's currently not possible based on how the params are passed from post to __request and into _this.request. Would you welcome a PR to allow params.headers in the options? If yes, would you like them to be removed from the query string before all the params used as the query string here: options.qs = params.

chrisdel101 commented 5 years ago

Did U ever solve this?

I am trying to pass either a buffer or a base64 image directly into the POST convenience method. It comes back as a 400 bad request. To make it work I'm currently making a file out of it first and then feeding this to node-twitter. This works but I don't like it.

seanpoulter commented 5 years ago

Unfortunately not @chrisdel101. I'd try asking on the StackOverflow post. I created the issue while trying to answer questions on StackOverflow and pay it forward. It looks like the repo hasn't had a commit to master since June 2017. I'd have a look at the conversation in #279 and consider the forked library there.