Pop chunk_size kwarg before initializing upload in API.chunked_upload
authorHarmon <Harmon758@gmail.com>
Thu, 23 Sep 2021 10:55:18 +0000 (05:55 -0500)
committerHarmon <Harmon758@gmail.com>
Thu, 23 Sep 2021 10:55:35 +0000 (05:55 -0500)
Resolves part of #1658

tweepy/api.py

index 61b0fd1c2dc43b4bf227ee5838c5206b243f49f9..5b69562076f24f7ad0d8f119ee666b867910e52d 100644 (file)
@@ -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(