try to set content type from the user's uploaded file. May be problematic.
improve error messages for error conditions