lookupMimeType function

String? lookupMimeType(
  1. String path, {
  2. List<int>? headerBytes,
})

Extract the extension from path and use that for MIME-type lookup, using the default extension map.

If no matching MIME-type was found, null is returned.

If headerBytes is present, a match for known magic-numbers will be performed first. This allows the correct mime-type to be found, even though a file have been saved using the wrong file-name extension. If less than defaultMagicNumbersMaxLength bytes was provided, some magic-numbers won't be matched against.

Implementation

String? lookupMimeType(String path, {List<int>? headerBytes}) =>
    _globalResolver.lookup(path, headerBytes: headerBytes);