I believe the TweetComposer in Twitter Kit 3 would wrap that for you, so you don’t have to implement the upload flow directly yourself. Twitter Kit is our Android and iOS SDK for integrating with Twitter.
If you want to see an example of the steps involved in uploading video in code, we have a sample written in Python that shows the overall flow of chunking the upload, checking the status, and attaching the media content to a Tweet.