Closed Scarlet06 closed 1 year ago
Could you provide image you try to upload?
The problem was with random images, sometimes it was uploading them and other times it was not for the same set of images.
But today, when I was testing specific files to share them with you... Everything was working fine as expected. I actually don't know what is going on, maybe a server problem with telegram? Anyway for now I'll close the issue.
Thank you very much for your time.
Sadly the problem started to show up again. Here the traceback
('Error while uploading the image', <Response [500]>)
File "***\Main.py", line 9278, in uploading
img = upload_image(self.images[self.i])
Exception: ('Error while uploading the image', <Response [500]>)
As I've mentioned above it happens randomly, sometime the same image is uploaded and sometimes it is rejected. As example, previously, I've managed to upload all these images without any problem. But today I couldn't reach the second image I would mention that the first image was uploaded at the third attempt. If you need, here you can find all the original images.
I made several false assumptions:
But after several attempts I can upload the image, so you can do something like this:
for attempt_number in range(5):
try:
print(f"uploading attempt {attempt_number} of 5")
upload_image("image_name.png")
break
except:
time.sleep(0.5)
So it actually is a problem with telegra.ph server! Thank you very much for your help and your time.
If at the end of the for loop it still didn't work (that can be checked by adding an else
statement after it), to make sure tho that the image would be loaded anyway I thounght about doing something like that:
from base64 import b64encode
with open("image_name.png","rb") as bytefile:
bf = b64encode(bytefile.read()).decode("utf-8")
image_source = f'"data:image/png;base64,{bf}"'
But then using img = f"<img src={image_source }>"
it doesn't work.
To me it doesn't look I'm doing something wrong and testing with a simple html file it seems I've done it right...
Can you please confirm that the only way to add images to telegraph is by using upload_image
? Or am I missing something?
ps: to be clear, to add the image to the telegraph page, I use the edit function, adding img
at the current text
@Scarlet06 I doubt that telegra.ph supports base64 images. At least there is a limit of 64kb for page content size. But you can upload images to any image hosting, which provides direct image url. This will definitely work
Thank you very much for your suggestion!
Recently, I have been experiencing an issue when trying to upload an image file using the command
html_telegraph_poster.upload_images("file_path.jpg")
. This issue has become more frequent, to the point where I am no longer able to upload images.Doing some testsing I was able to discover that the result of the request for the upload was
<Response [500]>
. I also tried to upload the image by myself imitating the method used here (changing some parameters) but without any success.But I've found this website, which could upload the same images without anz problem. Does anzone have anz solution for this?