Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit 2bf461f

Browse files
committed
use Response.content to perform automatic decoding for media downloads
1 parent b3ae763 commit 2bf461f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

twitter/twitter_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ def is_url(text):
211211
def http_to_file(http):
212212
data_file = NamedTemporaryFile()
213213
req = requests.get(http, stream=True)
214-
data_file.write(req.raw.data)
214+
for chunk in req.iter_content(chunk_size=1024 * 1024):
215+
data_file.write(chunk)
215216
return data_file
216217

217218

0 commit comments

Comments
 (0)