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

NAME

6       Dancer::MIME - Singleton object to handle MimeTypes
7

VERSION

9       version 1.3513
10

SYNOPSIS

12           # retrieve object instance
13           my $mime = Data::MIME->instance();
14
15           # return a hash reference of user defined types
16           my $types = $mime->custom_types;
17
18           # return the default mime-type for unknown files
19           $mime->default
20
21           # set the default mime-type with Dancer::Config or Dancer, like
22           set default_mime_type => "text/plain";
23           # or directly in your config.yml file.
24
25           # add non standard mime type
26           $mime->add_type( foo => "text/foo" );
27
28           # add an alias to an existing type
29           $mime->add_alias( bar => "foo" );
30
31           # get mime type for standard or non standard types
32           $nonstandard_type = $mime->for_name('foo');
33           $standard_type    = $mime->for_name('svg');
34
35           # get mime type for a file (given the extension)
36           $mime_type = $mime->for_file("foo.bar");
37

PUBLIC API

39   instance
40           my $mime = Dancer::MIME->instance();
41
42       return the Dancer::MIME instance object.
43
44   add_type
45           # add nonstandard mime type
46           $mime->add_type( foo => "text/foo" );
47
48       Add a non standard mime type or overrides an existing one.
49
50   add_alias
51           # add alias to standard or previous alias
52           $mime->add_alias( my_jpg => 'jpg' );
53
54       Adds an alias to an existing mime type.
55
56   for_name
57           $mime->for_name( 'jpg' );
58
59       Retrieve the mime type for a standard or non standard mime type.
60
61   for_file
62           $mime->for_file( 'file.jpg' );
63
64       Retrieve the mime type for a file, based on a file extension.
65
66   custom_types
67           my $types = $mime->custom_types;
68
69       Retrieve the full hash table of added mime types.
70
71   name_or_type
72           my $type = $mime->name_or_type($thing);
73
74       Resolves the $thing into a content $type whether it's the name of a
75       MIME type like "txt" or already a mime type like "text/plain".
76

AUTHORS

78       This module has been written and rewritten by different people from
79       Dancer project.
80

LICENCE

82       This module is released under the same terms as Perl itself.
83

SEE ALSO

85       Dancer
86

AUTHOR

88       Dancer Core Developers
89
91       This software is copyright (c) 2010 by Alexis Sukrieh.
92
93       This is free software; you can redistribute it and/or modify it under
94       the same terms as the Perl 5 programming language system itself.
95
96
97
98perl v5.32.1                      2021-01-27                   Dancer::MIME(3)
Impressum