I am tring to post an HTTP request using httplib2 that contains some xml and some binary data using this infoset:
MIME-Version: 1.0
Content-Type: Multipart/Related;boundary=MIME_boundary;
...
--MIME_boundary
Content-Type: application/xop+xml;
// [the xml string goes here...]
--MIME_boundary
Content-Type: image/png
Content-Transfer-Encoding: binary
Content-ID: <http://example.org/me.png>
// [the binary octets for png goes here...]
My approach is to generate a txt file, and then fill in the xml and the binary data.
I am having problem writing binary data to the file reading from the png with this:
pngfile = open(pngfile, "rb")
bindata = pngfile.read()
What's the best way to do this?