uploadMedia fails with buffer input
See original GitHub issueHi, I’ve been trying to use this wrapper for the upload media endpoint in a project and it works pretty well for local files but when I try to pass a buffer created from binary data it prompts:
Error: Failed to process media
This is how I get the binary data:
const getVideoBuffer = (previewUrl: string) => {
return new Promise((resolve, reject) => {
request.defaults({ encoding: null });
request.get(previewUrl!, async (error, response, body) => {
if (error) {
reject(new Error(`Something went wrong getting binary data from preview url ${error}`));
}
resolve(Buffer.from(body));
});
});
};
Here I get the buffer and start the upload:
const buffer: any = await getVideoBuffer(previewUrl || '');
const mediaId = await client.v1.uploadMedia(buffer, { type: 'mp4', target: 'tweet'});
const tweet = await client.v1.tweet('Hello!', { media_ids: mediaId });
console.log(tweet);
Am I missing something? Thanks in advance
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
Posts failing to save due to server issues - Buffer Help Center
To test if this is causing the issue, open Buffer in an incognito window, and then try scheduling the post again. If the...
Read more >Uploading and sharing links to videos - Buffer Help Center
There are two ways to share videos to your social channels through Buffer. The first way is to upload your video within the...
Read more >Error: Oops! Please edit the post - alter the copy/text, re-name ...
This could be by editing and changing the copy/text of the post, editing hashtags, removing links, re-uploading the media, and trying to publish...
Read more >Error: Oops! A timeout occurred while downloading the media ...
Rename the video file to something like video1. Upload the newly renamed video to the newly created post. Try sending out the new...
Read more >Troubleshooting failed Instagram posts - Buffer Help Center
The workaround to resolve this issue is to switch your Instagram account back to a personal profile and then reconvert it to a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @savannahar68, we just ended up using axios, here:
Then you would call
Good luck!
It was the
request
package, just noticed that is deprecated. Thanks a lot @alkihis , that solved the issue.