MIME::Types - determine mime type by file extension
A Raku library that reads the mime.types file as used by many Linux distributions, and web servers, and returns an object that can be queried by either type or extension.
use MIME::Types; # Specify the mime file you wisg to use # Or don't pass anything and get the default from the 'resources' directory my $mime = MIME::Types.new("/etc/mime.types"); my $type = $mime.type('txt'); ## Returns: 'text/plain'; my @known_extensions = $mime.extensions('application/vnd.ms-excel'); ## Returns: [ 'xls', 'xlb', 'xlt' ]
An example mime.types is included in the resources/ directory, and is used by the tests in t/.
This is licensed under the Artistic 2.0 license