SYNOPSIS

 use MIME::Types;
 my $mimetypes = MIME::Types->new;
 my MIME::Type $def = $mimetypes->type('text/plain');
 my MIME::Type $def = $mimetypes->mimeTypeOf('gif');

DESCRIPTION

MIME types are used in MIME compliant lines, for instance as part of e-mail and HTTP traffic, to indicate the type of content which is transmitted. Sometimes real knowledge about a mime-type is need.

This module maintains a set of MIME::Type objects, which each describe one known mime type. There are many types defined by RFCs and vendors, so the list is long but not complete. Please don't hestitate to ask to add additional information.

If you wish to get access to the mime.types files, which are available on various places in UNIX and Linux systems, then have a look at File::TypeInfo.

MIME::Types and mod_perl

This module uses a DATA handle to read all the types at first instantiation, which doesn't play nicely with mod_perl and fork.

When you use this module with mod_perl, add this to startup.pl

   use MIME::Types;
   BEGIN { MIME::Types->new() }

Now, the type definitions will get parsed before the processes are spawned.

MIME::Types and daemons (fork)

If your program uses fork (usually for a daemon), then the situation is a bit like with mod_perl before: you want to have the type table initialized before you start forking. So, first call

   my $mt = MIME::Types->new;

Later, each time you create this object (you may, of course, also reuse the object you create here) you will get access to the same global table of types.