METHODS

Constructors

$class->new( OPTIONS )

Create a new MIME::Types object which manages the data. In the current implementation, it does not matter whether you create this object often within your program, but in the future this may change.

Option Default

db_file

<installed source>

only_complete

<false>

only_iana

<false>

skip_extensions

<false>

db_file => FILENAME
only_complete => BOOLEAN
Only include complete MIME type definitions: requires at least one known extension. This will reduce the number of entries --and with that the amount of memory consumed-- considerably.
In your program you have to decide: the first time that you call the creator (new) determines whether you get the full or the partial information.
only_iana => BOOLEAN
Only load the types which are currently known by IANA.
skip_extensions => BOOLEAN
Do not load the table to map extensions to types, which is quite large.

Knowledge

$obj->addType( TYPE, ... )

Add one or more TYPEs to the set of known types. Each TYPE is a MIME::Type which must be experimental: either the main-type or the sub-type must start with C

Please inform the maintainer of this module when registered types are missing. Before version MIME::Types version 1.14, a warning was produced when an unknown IANA type was added. This has been removed, because some people need that to get their application to work locally... broken applications...

$obj->extensions

Returns a list of all defined extensions.

$obj->listTypes

Returns a list of all defined mime-types by name only. This will not instantiate MIME::Type objects. See types()

$obj->mimeTypeOf( FILENAME )

Returns the MIME::Type object which belongs to the FILENAME (or simply its filename extension) or undef if the file type is unknown. The extension is used and considered case-insensitive.

In some cases, more than one type is known for a certain filename extension. In that case, the preferred one is taken (for an unclear definition of preference)

» Example: use of mimeTypeOf()
 my $types = MIME::Types->new;
 my $mime = $types->mimeTypeOf('gif');

 my $mime = $types->mimeTypeOf('picture.jpg');
 print $mime->isBinary;
$obj->type( STRING )

Returns the MIME::Type which describes the type related to STRING. [2.00] Only one type will be returned.

[before 2.00] One type may be described more than once. Different extensions may be in use for this type, and different operating systems may cause more than one MIME::Type object to be defined. In scalar context, only the first is returned.

$obj->types

Returns a list of all defined mime-types. For reasons of backwards compatibility, this will instantiate MIME::Type objects, which will be returned. See listTypes().