Ævar Arnfjörð Bjarmason


Catalyst::Plugin::Upload::Digest - Compute digest of uploads with Digest


    use Catalyst qw< Upload::Digest >;

    if ( my $upload = $c->request->upload( 'field' ) ) {
        # Get Digest::Whirlpool object
        my $whirlpool = $upload->digest( 'Whirlpool' );

        # Get the digest of the uploaded file, addfile() has already
        # been called on its filehandle.
        my $hexdigest = $whirlpool->hexdigest;

        # I want a SHA-512 digest too!
        my $sha512digest = $upload->digest( 'SHA-512' )->digest;


Extends Catalyst::Request::Upload with a "digest" method that wraps Digest's construction method. Any arguments to it will be passed directly to Digest's constructor. The return value is the relevant digest object that has already been populated with the file handle of the uploaded file, so retrieving its digest will work as expected.


This module is distributed with a Catalyst example application called Upload::Digest, see the example/Upload-Digest directory in this distribution for how to run it.


To avoid being overly smart the digest method does not cache the digest for a given upload object / algorithm pair. If it is required to get the digest for a given file at two separate places in the program the user may wish to store the result somewhere to improve performance, or no do so because the speed of popular digest is likely not to become a bottleneck for most files.


Please report any bugs that aren't already listed at http://rt.cpan.org/Dist/Display.html?Queue=Catalyst-Plugin-Upload-Digest to http://rt.cpan.org/Public/Bug/Report.html?Queue=Catalyst-Plugin-Upload-Digest


Digest, Catalyst::Request::Upload


Ævar Arnfjörð Bjarmason <avar@cpan.org>


This library is free software . You can redistribute it and/or modify it under the same terms as Perl itself.