upload_video: 'string argument detected, got 'bytes' #422

Closed
opened 2016-05-31 21:34:58 -07:00 by choiRyan · 1 comment
choiRyan commented 2016-05-31 21:34:58 -07:00 (Migrated from github.com)

I first tried the following on Python 3.4 and Twython 3.4:

video = open(tempfile_name, 'rb')
response = twitter.upload_video(media=video, media_type='video/mp4')

and received an error:
media_chunk.write(data)
TypeError: string argument expected, got 'bytes'

I think using StringIO in Python3 instead of BytesIO in upload_video in endpoints.py led to this issue; on endpoints.py I changed the python3 import from io import StringIO (i.e. if StringIO.StringIO not found) to from io import BytesIO and upload_video now works with my last attempt (with the tempfile).

I first tried the following on Python 3.4 and Twython 3.4: `video = open(tempfile_name, 'rb')` `response = twitter.upload_video(media=video, media_type='video/mp4')` and received an error: `media_chunk.write(data)` `TypeError: string argument expected, got 'bytes'` I think using StringIO in Python3 instead of BytesIO in `upload_video` in `endpoints.py` led to this issue; on endpoints.py I changed the python3 import `from io import StringIO` (i.e. if StringIO.StringIO not found) to `from io import BytesIO` and `upload_video` now works with my last attempt (with the tempfile).
eliorkilometer commented 2017-04-25 05:42:41 -07:00 (Migrated from github.com)

Following twython video upload docs still results in TypeError: string argument expected, got 'bytes'

Any valid way to upload a post with video via Twython?

Following [twython video upload docs](https://twython.readthedocs.io/en/latest/usage/advanced_usage.html#updating-status-with-video) still results in `TypeError: string argument expected, got 'bytes'` Any valid way to upload a post with video via Twython?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: code/twython#422
No description provided.