NAME

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

SYNOPSIS

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;
}

DESCRIPTION

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.

EXAMPLE

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.

CAVEATS

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.

BUGS

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

SEE ALSO

Digest, Catalyst::Request::Upload

AUTHOR

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

LICENSE

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