From e4a588eb3fc5733fca81f67b01eb64e288cb887b Mon Sep 17 00:00:00 2001 From: Harmon Date: Thu, 23 Sep 2021 05:55:18 -0500 Subject: [PATCH] Pop chunk_size kwarg before initializing upload in API.chunked_upload Resolves part of #1658 --- tweepy/api.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tweepy/api.py b/tweepy/api.py index 61b0fd1..5b69562 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -3497,11 +3497,6 @@ class API: file_size = fp.tell() - start fp.seek(start) - media_id = self.chunked_upload_init( - file_size, file_type, media_category=media_category, - additional_owners=additional_owners, **kwargs - ).media_id - min_chunk_size, remainder = divmod(file_size, 1000) min_chunk_size += bool(remainder) @@ -3513,6 +3508,11 @@ class API: segments, remainder = divmod(file_size, chunk_size) segments += bool(remainder) + media_id = self.chunked_upload_init( + file_size, file_type, media_category=media_category, + additional_owners=additional_owners, **kwargs + ).media_id + for segment_index in range(segments): # The APPEND command returns an empty response body self.chunked_upload_append( -- 2.25.1