luckydonald / pytgbot

python module to access the telegram bot api.
MIT License
66 stars 16 forks source link

Image upload by InputFileFromURL fails. #3

Closed luckydonald closed 8 years ago

luckydonald commented 8 years ago

If failed with AttributeError: 'Response' object has no attribute 'read', due to the file to send being a Response (the downloaded stuff), but not the raw data from response.content.

#
#  • • •
#
File "/Users/luckydonald/Documents/Programmieren/Python/pytgbot.git/pytgbot/bot.py", line 426, in send_photo
 reply_to_message_id=reply_to_message_id, reply_markup=reply_markup
File "/Users/luckydonald/Documents/Programmieren/Python/pytgbot.git/pytgbot/bot.py", line 2034, in _do_fileupload
 return self.do("send{cmd}".format(cmd=file_param_name.capitalize()), **kwargs)
File "/Users/luckydonald/Documents/Programmieren/Python/pytgbot.git/pytgbot/bot.py", line 1983, in do
 verify=True, timeout=request_timeout)  # No self signed certificates. Telegram should be trustworthy anyway...
File "/Users/luckydonald/Documents/Programmieren/Python/telegram-brony-bot.git/virtualenv3.4.3/lib/python3.4/site-packages/requests/api.py", line 111, in post
 return request('post', url, data=data, json=json, **kwargs)
File "/Users/luckydonald/Documents/Programmieren/Python/telegram-brony-bot.git/virtualenv3.4.3/lib/python3.4/site-packages/requests/api.py", line 57, in request
 return session.request(method=method, url=url, **kwargs)
File "/Users/luckydonald/Documents/Programmieren/Python/telegram-brony-bot.git/virtualenv3.4.3/lib/python3.4/site-packages/requests/sessions.py", line 461, in request
 prep = self.prepare_request(req)
File "/Users/luckydonald/Documents/Programmieren/Python/telegram-brony-bot.git/virtualenv3.4.3/lib/python3.4/site-packages/requests/sessions.py", line 394, in prepare_request
 hooks=merge_hooks(request.hooks, self.hooks),
File "/Users/luckydonald/Documents/Programmieren/Python/telegram-brony-bot.git/virtualenv3.4.3/lib/python3.4/site-packages/requests/models.py", line 298, in prepare
 self.prepare_body(data, files, json)
File "/Users/luckydonald/Documents/Programmieren/Python/telegram-brony-bot.git/virtualenv3.4.3/lib/python3.4/site-packages/requests/models.py", line 449, in prepare_body
 (body, content_type) = self._encode_files(files, data)
File "/Users/luckydonald/Documents/Programmieren/Python/telegram-brony-bot.git/virtualenv3.4.3/lib/python3.4/site-packages/requests/models.py", line 152, in _encode_files
 fdata = fp.read()
AttributeError: 'Response' object has no attribute 'read'

Copy from https://github.com/luckydonald/bonbot/issues/131

luckydonald commented 8 years ago

Is the InputFileFromURL which fails.