Nils Bunger <nilsbun...@gmail.com> writes: > Hi Neil, > > Thanks for looking at this. > > I'm trying to create a multipart MIME for an HTTP POST request, not an > email. This is for a third-party API that requires a multipart POST > with a binary file, so I don't have the option to just use a different > encoding. > > Multipart HTTP is standardized in HTTP 1.0 and supports binary parts. > Also, no one will re-interpret contents of HTTP on the wire, as binary > is quite normal in HTTP. > > The issue seems to be some parts of the python MIME encoder still > assume it's for email only, where everything would be b64 encoded. > > Maybe I have to roll my own to create a multipart msg with a binary > file? I was hoping to avoid that.
The email MIME stuff is not really adapted for HTTP. I would advise to use the Requests package (http://docs.python-requests.org/en/latest/) or the Uploading Files part from Doug Hellmann's page (http://doughellmann.com/2009/07/pymotw-urllib2-library-for-opening-urls.html). This is for Python2; I can send you a Python3 version if you want. -- Piet van Oostrum <p...@vanoostrum.org> WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list