pub fn from_filepath(path: &Path) -> Option<&'static str>
Expand description

Gets the MIME type of a file.

Does not look at file name or extension, just the contents. Returns None if the file cannot be opened or if no matching MIME type is found.

Examples

use std::path::Path;

// Get path to a GIF file
let path = Path::new("tests/image/gif");

// Find the MIME type of the GIF
let result = tree_magic_mini::from_filepath(path);
assert_eq!(result, Some("image/gif"));