I already have binary data read from a file. Most of the examples I see online link directly to the file, and upload the whole file. I am looking how to upload the binary data that I already have from another source via HTTP POST in python.
2 Answers
I'm not sure what online examples you're looking at, but urllib2.urlopen takes the data to post as a chunk of data and not a file at all.
3 Comments
esac
I'll have to take a network sniff. The server that I am POST'ing to is issuing a 400 Bad Request when I try that.
Greg Hewgill
Okay, so that example reads the data from a file into
png_data. If you already have the data in memory, just use that in the calls to urllib2.