Summary
This is a bizarre error for a simple jpg type file (https://cdn1.epicgames.com/spt-assets/4c326848c77b4d9795b9262b789b6145/moonfire-a-seekers-saga-vao3b.jpg). Insta and Fb dont have this issue in posting.
Reproduction Steps
My script calls .media_upload(file_name) with .jpg type file (https://cdn1.epicgames.com/spt-assets/4c326848c77b4d9795b9262b789b6145/moonfire-a-seekers-saga-vao3b.jpg).
Code:
media = _client_v1.media_upload(filename=new_product_image_path)
Error:
File "/usr/local/lib/python3.10/site-packages/tweepy/api.py", line 3396, in media_upload
if chunked or file_type.startswith('video/'):
AttributeError: 'NoneType' object has no attribute 'startswith'
Minimal Reproducible Example
My script calls <client>.media_upload(file_name) with .jpg type file (https://cdn1.epicgames.com/spt-assets/4c326848c77b4d9795b9262b789b6145/moonfire-a-seekers-saga-vao3b.jpg).
Code:
media = _client_v1.media_upload(filename=new_product_image_path)
Error:
File "/usr/local/lib/python3.10/site-packages/tweepy/api.py", line 3396, in media_upload
if chunked or file_type.startswith('video/'):
AttributeError: 'NoneType' object has no attribute 'startswith'
Expected Results
return "media" type object
Actual Results
AttributeError: 'NoneType' object has no attribute 'startswith'
Twitter API Access Plan
Free
Tweepy Version
v1.1 for media_upload. No media_upload yet in v2.0
Checklist
Additional Context
if file is not None:
location = file.tell()
h = file.read(32)
file.seek(location)
file_type = imghdr.what(filename, h=h)
if file_type is not None:
file_type = 'image/' + file_type
else:
file_type = mimetypes.guess_type(filename)[0]
Summary
This is a bizarre error for a simple jpg type file (https://cdn1.epicgames.com/spt-assets/4c326848c77b4d9795b9262b789b6145/moonfire-a-seekers-saga-vao3b.jpg). Insta and Fb dont have this issue in posting.
Reproduction Steps
My script calls .media_upload(file_name) with .jpg type file (https://cdn1.epicgames.com/spt-assets/4c326848c77b4d9795b9262b789b6145/moonfire-a-seekers-saga-vao3b.jpg).
Code:
media = _client_v1.media_upload(filename=new_product_image_path)
Error:
File "/usr/local/lib/python3.10/site-packages/tweepy/api.py", line 3396, in media_upload
if chunked or file_type.startswith('video/'):
AttributeError: 'NoneType' object has no attribute 'startswith'
Minimal Reproducible Example
Expected Results
return "media" type object
Actual Results
AttributeError: 'NoneType' object has no attribute 'startswith'
Twitter API Access Plan
Free
Tweepy Version
v1.1 for media_upload. No media_upload yet in v2.0
Checklist
Additional Context