How can I make POST request with a file in Python mechanize, but without any existing form, I just need to POST a file "out of the blue". There are some examples of file upload on stackoverflow but all relate to attaching a file in a form.
I just need to generate a POST request with headers like:
Content-Length: 218853
Content-Type: application/octet-stream
Cookie: some-cookie-data
And in the POST data just the contents of a file from disk.
Cookies in the browser session need to be preserved, and I need to read back and process the response, which will be some Content-Type text/plain;
with some JSON.