Skip to main content
Version: 0.X.X

MimeTypes

The good news is that we also support the native Python library, mimetypes MimeTypes, and you can add it to your project as follows:

from file_validator.validators import file_validator_by_mimetypes

Just call this function and give the function path of the file and the mimes you want the files to be validated based on:

from file_validator.validators import file_validator_by_mimetypes

file_validator_by_mimetypes(acceptable_mimes=['audio/mpeg', 'video/mp4'], file_path='/path/to/file')
info

Description of the return value and the function parameters:

ParametersTypeDescription
file_pathstringThe path to the file you want to validate
acceptable_mimeslistThe mime of the files you want to validate based on them, example: image/png
Returns:
If everything is OK it will return information about file such file name,file type, file mime, file extensions , otherwise it will return a FileValidationException.