mime_types 0.0.1 mime_types: ^0.0.1 copied to clipboard
A helper-package for working MIME and content types.
mime_types #
A Dart helper-package for working MIME and content types.
It differs from Google's MIME in two main ways:
- Content type lookup doesn't take file contents (magic bytes) into account - it's purely based on an extension or file name.
- The library provides both content type-to-extension AND extension-to-content type mapping.
MIME/content type database from [https://github.com/jshttp/mime-db]
Usage #
import 'package:mime_types/mime_types.dart' as mime;
main() {
print(mime.extension('image/jpeg')); // jpeg
print(mime.extension('application/pdf')); // pdf
print(mime.contentType('jpg')); // image/jpeg
print(mime.contentType('pdf')); // application/pdf
print(mime.contentType('/path/to/file.txt')); // text/plain
}
Running tests #
pub run test test