You should probably just pass the file to the requests library and have it do all the work, like setting up multipart/form-data and Content-Disposition. I don't often write Python, but this looks like the right approach: http://stackoverflow.com/a/22567429