1MIME::Types(3)        User Contributed Perl Documentation       MIME::Types(3)
2
3
4

NAME

6       MIME::Types - Definition of MIME types
7

INHERITANCE

9        MIME::Types
10          is an Exporter
11

SYNOPSIS

13        use MIME::Types;
14        my $mimetypes = MIME::Types->new;
15        my MIME::Type $plaintext = $mimetypes->type('text/plain');
16        my MIME::Type $imagegif  = $mimetypes->mimeTypeOf('gif');
17

DESCRIPTION

19       MIME types are used in MIME compliant lines, for instance as part of
20       e-mail and HTTP traffic, to indicate the type of content which is
21       transmitted.  Sometimes real knowledge about a mime-type is need.
22
23       This module maintains a set of MIME::Type objects, which each describe
24       one known mime type.  There are many types defined by RFCs and vendors,
25       so the list is long but not complete.  Please don't hestitate to ask to
26       add additional information.
27

METHODS

29       Instantiation
30
31       MIME::Types->new(OPTIONS)
32
33           Create a new "MIME::Types" object which manages the data.  In the
34           current implementation, it does not matter whether you create this
35           object often within your program, but in the future this may
36           change.
37
38            Option       --Default
39            only_complete  <false>
40
41           . only_complete BOOLEAN
42
43               Only include complete MIME type definitions: requires at least
44               one known extension.  This will reduce the number of entries
45               --and with that the amount of memory consumed-- considerably.
46
47               In your program you have to decide: the first time that you
48               call the creator ("new") determines whether you get the full or
49               the partial information.
50
51       Knowledge
52
53       $obj->addType(TYPE, ...)
54
55           Add one or more TYPEs to the set of known types.  Each TYPE is a
56           "MIME::Type" which must be experimental: either the main-type or
57           the sub-type must start with "x-".
58
59           Please inform the maintainer of this module when registered types
60           are missing.  Before version MIME::Types version 1.14, a warning
61           was produced when an unknown IANA type was added.  This has been
62           removed, because some people need that to get their application to
63           work locally... broken applications...
64
65       $obj->extensions
66
67           Returns a list of all defined extensions.
68
69       $obj->mimeTypeOf(FILENAME)
70
71           Returns the "MIME::Type" object which belongs to the FILENAME (or
72           simply its filename extension) or "undef" if the file type is
73           unknown.  The extension is used, and considered case-insensitive.
74
75           In some cases, more than one type is known for a certain filename
76           extension.  In that case, one of the alternatives is chosen at ran‐
77           dom.
78
79           Example: use of mimeTypeOf()
80
81            my MIME::Types $types = MIME::Types->new;
82            my MIME::Type  $mime = $types->mimeTypeOf('gif');
83
84            my MIME::Type  $mime = $types->mimeTypeOf('jpg');
85            print $mime->isBinary;
86
87       $obj->type(STRING)
88
89           Return the "MIME::Type" which describes the type related to STRING.
90           One type may be described more than once.  Different extensions is
91           use for this type, and different operating systems may cause more
92           than one "MIME::Type" object to be defined.  In scalar context,
93           only the first is returned.
94
95       $obj->types
96
97           Returns a list of all defined mime-types
98

FUNCTIONS

100       The next functions are provided for backward compatibility with
101       MIME::Types versions 0.06 and below.  This code originates from Jeff
102       Okamoto okamoto@corp.hp.com and others.
103
104       by_mediatype(TYPE)
105
106           This function takes a media type and returns a list or anonymous
107           array of anonymous three-element arrays whose values are the file
108           name suffix used to identify it, the media type, and a content
109           encoding.
110
111           TYPE can be a full type name (contains '/', and will be matched in
112           full), a partial type (which is used as regular expression) or a
113           real regular expression.
114
115       by_suffix(FILENAME⎪SUFFIX)
116
117           Like "mimeTypeOf", but does not return an "MIME::Type" object. If
118           the file +type is unknown, both the returned media type and encod‐
119           ing are empty strings.
120
121           Example: use of function by_suffix()
122
123            use MIME::Types 'by_suffix';
124            my ($mediatype, $encoding) = by_suffix 'image.gif';
125
126            my $refdata =  by_suffix 'image.gif';
127            my ($mediatype, $encoding) = @$refdata;
128
129       import_mime_types
130
131           This method has been removed: mime-types are only useful if under‐
132           stood by many parties.  Therefore, the IANA assigns names which can
133           be used.  In the table kept by this "MIME::Types" module all these
134           names, plus the most often used termporary names are kept.  When
135           names seem to be missing, please contact the maintainer for inclus‐
136           sion.
137

SEE ALSO

139       This module is part of MIME-Types distribution version 1.19, built on
140       March 25, 2007. Website: http://perl.overmeer.net/mimetypes/
141

LICENSE

143       Copyrights 1999,2001-2007 by Mark Overmeer.For other contributors see
144       ChangeLog.
145
146       This program is free software; you can redistribute it and/or modify it
147       under the same terms as Perl itself.  See
148       http://www.perl.com/perl/misc/Artistic.html
149
150
151
152perl v5.8.8                       2007-03-25                    MIME::Types(3)
Impressum