0

I want to upload a picture in python. This doesn't work without specifying the content-length. Sadly I don't know how to calculate it manually nor automatically. I tried to encode the picture and adding the body and then send the content-length. No success. I hope u can help me. I use python requests.

payload = {'num_media_pending': '0',

'type': 'photo'}

Alex K
  • 1
  • 1
  • Have a look there, how to get the filesize of a file in Python: https://stackoverflow.com/questions/2104080/how-can-i-check-file-size-in-python – Maurice Meyer May 28 '20 at 08:53
  • Does this answer your question? [How to get image size (bytes) using PIL](https://stackoverflow.com/questions/11904083/how-to-get-image-size-bytes-using-pil) –  May 28 '20 at 21:20

0 Answers0