django_auxilium.utils.content_type module

django_auxilium.utils.content_type.get_content_type(f)[source]

Get content_type of a file by using magic library

Parameters:f (str or file) – Either a binary string of a file content or a file-like object from which file data will be read
Returns:Content-type of a file as string
Return type:str
django_auxilium.utils.content_type.get_content_type_from_binary(data)[source]

Get content_type of a binary string by using magic library

Parameters:data (binary) – Binary string data of a file from which content_type will be determined
Returns:Content-type of a file as string
Return type:str
django_auxilium.utils.content_type.get_content_type_from_file(f)[source]

Get content_type of a file-like object by using magic library

Note

This function reads first 1Kb of the file in order to determine the content_type however at the end seeks back to 0

Parameters:f (file) – File-like object which should implement .seek() and .read() methods from which content_type will be determined
Returns:Content-type of a file as string
Return type:str