Closed govorushagreat closed 6 years ago
Can you try to use upload_file
function?
print(telegraph.upload_file('C:/Users/Admin/Desktop/photo_2018-08-13_16-31-15.jpg'))
I get the "'Telegraph' object has no attribute 'upload_file'", but the library is correctly installed in the environment
The most interesting point is that a week ago there were no problems
Just a week ago this code was working: photo = open(path, 'rb') new_path = requests.post( 'http://telegra.ph/upload', files={'file': ('file', photo, 'image/jpeg')}).json()[0]['src'] content += "".format(new_path)
Replace http
with https
Did not help
Try to install the module via
pip install https://github.com/python273/telegraph/archive/master.zip
and use
print(telegraph.upload_file('C:/Users/Admin/Desktop/photo_2018-08-13_16-31-15.jpg'))
import requests
with open('C:/Users/Admin/Desktop/photo_2018-08-13_16-31-15.jpg', 'rb') as f: print( requests.post( 'http://telegra.ph/upload', files={'file': ('file', f, 'image/jpg')} # image/gif, image/jpeg, image/jpg, image/png, video/mp4 ).json() )
Result: {'error': 'No files passed'}
Аny ideas?