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

Gets the type of a file from a filepath.

Does not look at file name or extension, just the contents. Returns MIME as string wrapped in Some if a type matches, or None if the file is not found or cannot be opened.

§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"));