I\'m interested in writing a short python script which uploads a short binary file (.wav/.raw audio) via a POST request to a remote server.
I\'ve done this with pycurl,
POSTing a file requires multipart/form-data
encoding and, as far as I know, there's no easy way (i.e. one-liner or something) to do this with the stdlib. But as you mentioned, there are plenty of recipes out there.
Although they seem verbose, your use case suggests that you can probably just encapsulate it once into a function or class and not worry too much, right? Take a look at the recipe on ActiveState and read the comments for suggestions:
or see the MultiPartForm
class in this PyMOTW, which seems pretty reusable:
I believe both handle binary files.