Function mime_guess::guess_mime_type

source ·
pub fn guess_mime_type<P: AsRef<Path>>(path: P) -> Mime
👎Deprecated since 2.0.0: Use from_path(path).first_or_octet_stream() instead
Expand description

Guess the MIME type of path by its extension (as defined by Path::extension()).

If path has no extension, or its extension has no known MIME type mapping, then the MIME type is assumed to be application/octet-stream.

§Note

Guess is the operative word here, as there are no guarantees that the contents of the file that path points to match the MIME type associated with the path’s extension.

Take care when processing files with assumptions based on the return value of this function.

In HTTP applications, it might be preferable to not send a Content-Type header at all instead of defaulting to application/octet-stream.