mime_types 0.0.1 copy "mime_types: ^0.0.1" to clipboard
mime_types: ^0.0.1 copied to clipboard

Dart 1 only

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:

  1. Content type lookup doesn't take file contents (magic bytes) into account - it's purely based on an extension or file name.
  2. 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

0
likes
30
pub points
14%
popularity

Publisher

unverified uploader

A helper-package for working MIME and content types.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

More

Packages that depend on mime_types