pdf static method
Sniffs a PDF document.
Reference: https://www.loc.gov/preservation/digital/MediaTypes/fdd/fdd000123.shtml
Implementation
static Future<MediaType?> pdf(SnifferContext context) async {
if (context.hasFileExtension(["pdf"]) ||
context.hasMediaType("application/pdf")) {
return MediaType.pdf;
}
if ((await context.read(range: IntRange(0, 5)))?.asUtf8() == "%PDF-") {
return MediaType.pdf;
}
return null;
}