line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Plugin::Upload::MIME; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1006
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
570
|
use Catalyst::Request::Upload; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use File::MimeInfo::Magic (); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
{ |
10
|
|
|
|
|
|
|
package Catalyst::Request::Upload; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub mimetype { |
13
|
|
|
|
|
|
|
my $self = shift; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
unless ( $self->{mimetype} ) { |
16
|
|
|
|
|
|
|
$self->{mimetype} ||= File::MimeInfo::Magic::magic( $self->tempname ); |
17
|
|
|
|
|
|
|
$self->{mimetype} ||= File::MimeInfo::Magic::default( $self->tempname ); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return $self->{mimetype}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub extension { |
24
|
|
|
|
|
|
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
unless ( $self->{extension} ) { |
27
|
|
|
|
|
|
|
$self->{extension} = File::MimeInfo::Magic::extensions( $self->mimetype ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return $self->{extension}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 NAME |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Catalyst::Plugin::Upload::MIME - MIME type for uploads |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
use Catalyst qw[Upload::MIME]; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
if ( my $upload = $c->request->upload('field') ) { |
47
|
|
|
|
|
|
|
print $upload->mimetype; |
48
|
|
|
|
|
|
|
print $upload->extension; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Extends C<Catalyst::Request::Upload> with C<MIME type> magic. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 METHODS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=over 4 |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item extension |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Returns file extension for C<mimetype>. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item mimetype |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Returns C<MIME type> for tempname using magic. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=back |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SEE ALSO |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L<File::MimeInfo::Magic>, L<Catalyst::Request>, L<Catalyst::Request::Upload>. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Christian Hansen, C<ch@ngmedia.com> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 LICENSE |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This library is free software . You can redistribute it and/or modify it under |
81
|
|
|
|
|
|
|
the same terms as perl itself. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |