Added a dependency to a mimetypes library.
Ignore unused variables.
Set the Content-type properly.
Moved to several function heads for upload_file so the user has a finer control over how the request is dealt with.
Export the new functions.