sferik / twitter-ruby

A Ruby interface to the Twitter API.
http://www.rubydoc.info/gems/twitter
MIT License
4.58k stars 1.31k forks source link

Fix chunk upload when media is used before twitter tells us it's ready #937

Closed FabienChaynes closed 4 years ago

FabienChaynes commented 6 years ago

Hi,

As stated in this post, when sending media in chunk, at the FINALIZE step the status needs to be checked:

If and (only if) the response of the FINALIZE command contains a processing_info field, it may also be necessary to use a STATUS command and wait for it to return success before proceeding to Tweet creation.

If the media processing is not finished on Twitter side and we try to send a tweet using it, it'll fail with There was an error sending your message: Bad Media, unable to process: None..

This PR updates REST::UploadUtils#chunk_upload to handle those cases. A special case was added to Twitter::REST::Request#error to handle media exceptions because Twitter returns a 200 in those cases. A new MediaError exception class was added with other specialized subclasses.

marckohlbrugge commented 5 years ago

This fixes #956 for me. I hope this PR gets merged someday 👍

deanpcmad commented 4 years ago

This fixes my issue too. Hope it gets merged :+1: