| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catalyst::Plugin::Upload::Digest; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
3
|
1
|
|
|
1
|
|
873
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
39
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
493
|
use Catalyst::Request::Upload; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Digest; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
{ |
|
9
|
|
|
|
|
|
|
package Catalyst::Request::Upload; |
|
10
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub digest { |
|
13
|
|
|
|
|
|
|
my $self = shift; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Digest->new( @_ )->addfile( $self->fh ); |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
1; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__END__ |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Catalyst::Plugin::Upload::Digest - Compute digest of uploads with L<Digest> |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Catalyst qw< Upload::Digest >; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
if ( my $upload = $c->request->upload( 'field' ) ) { |
|
32
|
|
|
|
|
|
|
# Get Digest::Whirlpool object |
|
33
|
|
|
|
|
|
|
my $whirlpool = $upload->digest( 'Whirlpool' ); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Get the digest of the uploaded file, addfile() has already |
|
36
|
|
|
|
|
|
|
# been called on its filehandle. |
|
37
|
|
|
|
|
|
|
my $hexdigest = $whirlpool->hexdigest; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# I want a SHA-512 digest too! |
|
40
|
|
|
|
|
|
|
my $sha512digest = $upload->digest( 'SHA-512' )->digest; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Extends C<Catalyst::Request::Upload> with a L</digest> method that |
|
46
|
|
|
|
|
|
|
wraps L<Digest>'s L<construction|Digest/"OO INTERFACE"> method. Any |
|
47
|
|
|
|
|
|
|
arguments to it will be passed directly to Digest's constructor. The |
|
48
|
|
|
|
|
|
|
return value is the relevant digest object that has already been |
|
49
|
|
|
|
|
|
|
populated with the file handle of the uploaded file, so retrieving its |
|
50
|
|
|
|
|
|
|
digest will work as expected. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 EXAMPLE |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This module is distributed with a Catalyst example application called |
|
55
|
|
|
|
|
|
|
B<Upload::Digest>, see the F<example/Upload-Digest> directory in this |
|
56
|
|
|
|
|
|
|
distribution for how to run it. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 CAVEATS |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
To avoid being overly smart the C<digest> method does not cache the |
|
61
|
|
|
|
|
|
|
digest for a given upload object / algorithm pair. If it is required |
|
62
|
|
|
|
|
|
|
to get the digest for a given file at two separate places in the |
|
63
|
|
|
|
|
|
|
program the user may wish to store the result somewhere to improve |
|
64
|
|
|
|
|
|
|
performance, or no do so because the speed of popular digest is likely |
|
65
|
|
|
|
|
|
|
not to become a bottleneck for most files. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 BUGS |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Please report any bugs that aren't already listed at |
|
70
|
|
|
|
|
|
|
L<http://rt.cpan.org/Dist/Display.html?Queue=Catalyst-Plugin-Upload-Digest> to |
|
71
|
|
|
|
|
|
|
L<http://rt.cpan.org/Public/Bug/Report.html?Queue=Catalyst-Plugin-Upload-Digest> |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L<Digest>, L<Catalyst::Request::Upload> |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org> |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 LICENSE |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This library is free software . You can redistribute it and/or modify it under |
|
84
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |