From 9ad23eabb073d140d7db9847370720c304ba0899 Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 13 Jan 2021 13:49:41 -0600 Subject: [PATCH] Improve comments in API.chunked_upload --- tweepy/api.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tweepy/api.py b/tweepy/api.py index 1a51753..9e744c1 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -254,9 +254,6 @@ class API: """ :reference https://developer.twitter.com/en/docs/media/upload-media/uploading-media/chunked-media-upload :allowed_param: """ - # Media category is dependant on whether media is attached to a tweet - # or to a direct message. Assume tweet by default. - fp = file or open(filename, 'rb') start = fp.tell() @@ -271,9 +268,9 @@ class API: min_chunk_size, remainder = divmod(file_size, 1000) min_chunk_size += bool(remainder) - # Default chunk size, in bytes, 1 MB is given as example chunk size in Twitter API docs - # The max is given in the docs as 5 MB. + # Use 1 MiB as default chunk size chunk_size = kwargs.pop('chunk_size', 1024 * 1024) + # Max chunk size is 5 MiB chunk_size = max(min(chunk_size, 5 * 1024 * 1024), min_chunk_size) segments, remainder = divmod(file_size, chunk_size) -- 2.25.1