CGI-Application-Plugin-Stream

 view release on metacpan or  search on metacpan

lib/CGI/Application/Plugin/Stream.pm  view on Meta::CPAN

@ISA = qw(Exporter);

@EXPORT_OK = qw(stream_file);

our $VERSION = '2.12';

sub stream_file {
    my ( $self, $file_or_fh, $bytes ) = @_;
    $bytes ||= 1024;
    my ($fh, $basename);
    my  $size = (stat( $file_or_fh ))[7];

    # If we have a file path
    if ( ref( \$file_or_fh ) eq 'SCALAR' ) {
        # They passed along a scalar, pointing to the path of the file
        # So we need to open the file
        open($fh,"<$file_or_fh"  ) || return 0;
        # Now let's go binmode (Thanks, William!)
        binmode $fh;
        $basename = basename( $file_or_fh );
    }



( run in 0.680 second using v1.01-cache-2.11-cpan-49f99fa48dc )