Rework media uploading - #1486
Merged
Merged
Conversation
* And safe import urllib in both py2/3 * rename methods to match API * DRY max sizes, put in class in case twitter changes them * use single media_upload for image and video, send to standard or * chunked upload based on mime type and size * finalize needs ModelParser, not RawParser
Add minimum chunk size of 16K, keeps number of chunks under 999
Adds video upload
Merged
Add and use additional_owners, file, filename, and media_category documented parameters
So as to refer to uploading media rather than only images
Member
Author
|
@LuisMayo As per our discussion in #1414, I've added a |
Harmon758
marked this pull request as ready for review
February 21, 2021 05:21
Member
Author
|
This branch/pull request should be complete now. Any feedback and/or review from @Choko256, @fitnr, @jamesandres, @jamiewinspear, @LuisMayo, @Maradonna90, or anyone else would be appreciated. |
This was referenced Feb 21, 2021
Closed
Closed
Closed
Closed
Contributor
|
The code looks a lot cleaner to me. Worked perfectly in a quick manual test. |
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds
API.simple_upload,API.chunked_upload_init,API.chunked_upload_append,API.chunked_upload_finalize, andAPI.get_media_upload_status. It also addsAPI.chunked_upload, which callsAPI.chunked_upload_init,API.chunked_upload_append, andAPI.chunked_upload_finalize, as well asAPI.get_media_upload_statuswhen thewait_for_async_finalizeparameter is set, and handles the entire chunked upload process.API.simple_uploaduses the simple image upload endpoint asAPI.media_uploaddid, whileAPI.media_uploadnow calls eitherAPI.simple_uploadorAPI.chunked_upload, depending on whether thechunkedparameter is set and if the media being uploaded is a video.With support for chunked upload, this allows for uploading videos and large GIFs, which resolves #640 and resolves #1501, respectively.
Media upload methods now use the
dataandfilesparameters of the requests library'sSession.request, replacingAPI._pack_image, which has now been removed.Additionally, there are numerous other improvements, optimizations, etc. to the media upload API methods.
This pull request is based on #655, #672, #929, and #1414, with contributions from @Choko256, @fitnr, @jamesandres, @jamiewinspear, and @Maradonna90, but I've refactored/removed/rewritten almost all of the code from those pull requests.