def get_content_type(name, content):
if hasattr(content, "<STR_LIT>"):<EOL><INDENT>content_type = content.content_type<EOL><DEDENT>else:<EOL><INDENT>mime_type, encoding = mimetypes.guess_type(name)<EOL>content_type = mime_type<EOL><DEDENT>return content_type<EOL>
Checks if the content_type is already set.
Otherwise uses the mimetypes library to guess.