NAME
MIME::Types - Definition of MIME types
SYNOPSIS
use MIME::Types;
my $mimetypes = MIME::Types->new;
my MIME::Type $plaintext = $mimetype->type('text/plain');
my MIME::Type $imagegif = $mimetype->extension('gif');
DESCRIPTION
MIME types are used in MIME entities, for instance as part of e-mail and HTTP traffic. Sometimes real knowledge about a mime-type is need. This module will supply it.
METHODS
- 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.OPTIONS DEFAULT only_complete 0
only_complete => BOOLEAN
Only include complete mime-type definitions: requires extension and encoding. This will reduce the number of entries --and with that the amount of memory consumed-- enormously.
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.
- type STRING
-
Return the
MIME::Type
which describes the type related to STRING. One type may be described more than once. Different extensions is use for this type, and different operating systems may cause more than oneMIME::Type
object to be defined. In scalar context, only the first is returned. - mimeTypeOf FILENAME
-
Returns the
MIME::Type
object which belongs to the FILENAME (or simply its filename extension). The extension is used, and considered case-insensitive.Examples:
my MIME::Types $types = MIME::Types->new; my MIME::Type $mime = $types->mimeTypeOf('gif'); my MIME::Type $mime = $types->mimeTypeOf('jpg'); print $mime->isBinary;
EXPORT
The next methods are provided for backward compatibility with MIME::Types versions 0.06 and below. This code originates from Jeff Okamoto <okamoto@corp.hp.com> and others.
- by_suffix FILENAME|SUFFIX
-
Like
mimeTypeOf
but does not return anMIME::Type
object.Example:
use MIME::Types 'by_suffix'; my ($mediatype, $encoding) = by_suffix 'image.gif'; my $refdata = by_suffix 'image.gif'; my ($mediatype, $encoding) = @$refdata;
- by_mediatype TYPE
-
This function takes a media type and returns a list or anonymous array of anonymous three-element arrays whose values are the file name suffix used to identify it, the media type, and a content encoding.
TYPE can be a full type name (contains '/', and will be matched in full), a partial type (which is used as regular expression) or a real regular expression.
- import_mime_types
-
This method has been removed, because it was primarily used to add info from the Apache mime definitions to the tables of
MIME::Types
. However this data is included now by default, so the method is not useful anymore and will croak.
SEE ALSO
AUTHOR
Original module and data collection by Jeff Okamoto and the Apache team. Mark Overmeer (mimetypes@overmeer.net). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
VERSION
This code is beta version 0.12.
Copyright (c) 2001 by Jeff Okamoto and Mark Overmeer. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.