table of contents
MIME::Types(3) | User Contributed Perl Documentation | MIME::Types(3) |
NAME¶
MIME::Types - Definition of MIME types
INHERITANCE¶
MIME::Types is a Exporter
SYNOPSIS¶
use MIME::Types; my $mimetypes = MIME::Types->new; my MIME::Type $plaintext = $mimetypes->type('text/plain'); my MIME::Type $imagegif = $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.
METHODS¶
Instantiation¶
MIME::Types->new(OPTIONS)
Option --Default only_complete <false>
. only_complete => BOOLEAN
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.
Knowledge¶
$obj->addType(TYPE, ...)
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
$obj->mimeTypeOf(FILENAME)
In some cases, more than one type is known for a certain filename extension. In that case, one of the alternatives is chosen at random.
example: use of mimeTypeOf()
my MIME::Types $types = MIME::Types->new; my MIME::Type $mime = $types->mimeTypeOf('gif'); my MIME::Type $mime = $types->mimeTypeOf('jpg'); print $mime->isBinary;
$obj->type(STRING)
$obj->types
FUNCTIONS¶
The next functions 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_mediatype(TYPE)
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.
by_suffix(FILENAME|SUFFIX)
example: use of function by_suffix()
use MIME::Types 'by_suffix'; my ($mediatype, $encoding) = by_suffix 'image.gif'; my $refdata = by_suffix 'image.gif'; my ($mediatype, $encoding) = @$refdata;
import_mime_types
SEE ALSO¶
This module is part of MIME-Types distribution version 1.28, built on September 07, 2009. Website: http://perl.overmeer.net/mimetypes/
LICENSE¶
Copyrights 1999,2001-2009 by Mark Overmeer. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html
2009-09-06 | perl v5.10.1 |