Function from_file

Source
pub fn from_file(file: &File) -> Option<Mime>
Expand description

Gets the MIME type for a file.

Does not look at file name or extension, just the contents.

ยงExamples

use std::fs::File;

// Get path to a GIF file
let file = File::open("./tests/inputs/image/gif/gif.gif").unwrap();

// Find the MIME type of the GIF
let result = tika_magic::from_file(&file);
assert_eq!(result, Some("image/gif"));