Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postMediaChunked results in "Segments do not add up to provided total file size" twitter API error #521

Closed
skorasaurus opened this issue Nov 22, 2019 · 1 comment

Comments

@skorasaurus
Copy link

skorasaurus commented Nov 22, 2019

When uploading photos to twitter using the postMediaChunked method, I often get an error (~50%) from twitter's api:

"Segments do not add up to provided total file size"

My smallest test case is available (you'll have to provide your own env keys)
is https://glitch.com/edit/#!/alkaline-firewall?path=server.js:113:57

To reproduce:

  1. open the glitch link; (will need to sign up to edit )
  2. add your twitter credentials
  3. click left side, lower-left hand corner click 'tools' then LOGS;
  4. set myRandomINT to an integer between 1 and 8900 or use the function in there to generate one.

Upon any modification to the code in glitch, glitch automatically run the project; then visit the endpoint that you designate (it's in .env).

What I expect:
When the photo is successfully uploaded;

I'm not sure if it's a problem with twitter's API or if it's with twit just yet.

I'm using twit 2.2.11 but modified one additional commit - #456
added to it; correcting the highWaterMark variable. I also encountered this same error when I was just using vanilla twit 2.2.11

@skorasaurus
Copy link
Author

Nope, I'm pretty sure it was just a problem with my code;

I was downloading a photo from a 3rd party api, saving it locally on the server, then uploading it to twitter.
What I think was happening was that the photo was not finished downloading before postMediaChunked was called.

I add an event so that postMediaChunked (in a callback) wasn't called until after the photo was finished downloading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant