python273 / telegraph

Telegraph API wrapper | Telegra.ph
https://pypi.org/project/telegraph/
MIT License
287 stars 43 forks source link

upload_file Error #55

Open Haruto-hyuuga opened 11 months ago

Haruto-hyuuga commented 11 months ago

File "/usr/local/lib/python3.8/site-packages/telegraph/upload.py", line 13, in upload_file r = TelegraphApi().upload_file(f) File "/usr/local/lib/python3.8/site-packages/telegraph/api.py", line 56, in upload_file response = self.session.post( File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 975, in json RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

PavelKucherenko commented 10 months ago

I have the same issue today when I try to upload .jpg file.. Does anybody know the solution? Thanks in adance!

UPD: Solved for now when I turned off my VPN.. Don't know why, VPN works fine for browsing etc.

Haruto-hyuuga commented 10 months ago

I have the same issue today when I try to upload .jpg file.. Does anybody know the solution? Thanks in adance!

UPD: Solved for now when I turned off my VPN.. Don't know why, VPN works fine for browsing etc.

I have the same issue today when I try to upload .jpg file.. Does anybody know the solution? Thanks in adance!

UPD: Solved for now when I turned off my VPN.. Don't know why, VPN works fine for browsing etc.

You can use try and except block, like try to upload_file Except use httpx/aiohttp Libraray as client to upload file to telegraph.ph like "https://telegra.ph/upload", data={"upload-file": your-file}