I want to upload a file to a web server. From what I read, the best way to do this is to use the multipart / form-data encoding type in the HTTP POST request.
My research shows that there is no easy way to do this using the standard Python library. I am using Python 3.
(Note: see the requests package ( PyPI Link ) for easy implementation)
I am currently using this method:
import mimetypes, http.client boundary = 'wL36Yn8afVp8Ag7AmP8qZ0SA4n1v9T'
This works to send text.
There are two problems: this is only text, and the entire text file must be stored in memory as a giant string.
How can I download any binary file? Is there a way to do this without reading the entire file in memory?
source share