Apache2-FileHash

 view release on metacpan or  search on metacpan

FileHash.yml  view on Meta::CPAN

    method: http
    name: localhost
    port: 80
  -
    method: http
    name: localhost
    port: 8080
METHOD:
  GET:
    root_uri: '/getFile'
  PUT:
    root_uri: '/storeFile'

MANIFEST  view on Meta::CPAN

Changes
FileHash.yml
MANIFEST
Makefile.PL
README
lib/Apache2/FileHash.pm
lib/Apache2/FileHash/GET.pm
lib/Apache2/FileHash/PUT.pm
startup.pl
t/Apache2-FileHash.t
META.yml                                 Module meta-data (added by MakeMaker)

lib/Apache2/FileHash.pm  view on Meta::CPAN

=head1 NAME

Apache2::FileHash - Methods to store and retrieve files using a hashing methodology.

=head1 SYNOPSIS

  use Apache2::FileHash;

  <VirtualHost *:80>
      <Location /storeFile>
          PerlHeaderParserHandler Apache2::FileHash::PUT
          <Limit PUT> 
              order deny,allow
              deny from all 
              allow from 192.168.5.5
          </Limit> 
      </Location>
   
      <Location /getFile>
          PerlHeaderParserHandler Apache2::FileHash::GET
      </Location>
  </VirtualHost>

  <VirtualHost *:8080>
      <Location /storeFile>
          PerlHeaderParserHandler Apache2::FileHash::PUT
          <Limit PUT> 
              order deny,allow
              deny from all 
              allow from 192.168.5.5
          </Limit> 
      </Location>

      <Location /getFile>
          PerlHeaderParserHandler Apache2::FileHash::GET
      </Location>
  </VirtualHost>

lib/Apache2/FileHash.pm  view on Meta::CPAN


    use strict;
    use warnings;

    use lib qw(/opt/mod_perl);
    use lib qw(/opt/mod_perl/lib);
    use lib qw(/opt/Apache2);
    use lib qw(/opt/Apache2/FileHash);

    use Apache2::FileHash;
    use Apache2::FileHash::PUT;
    use Apache2::FileHash::GET;

    use MIME::Types;

    my @array = ();
    foreach my $dir (@INC) {
        my $file = "$dir/$Apache2::FileHash::ConfigFile";
        eval {
            @array = &YAML::Tiny::LoadFile($file) or die("LoadFile($YAML::Tiny::errstr)");
        };

lib/Apache2/FileHash.pm  view on Meta::CPAN

        method: http
        name: localhost
        port: 80
      -
        method: http
        name: localhost
        port: 8080
    METHOD:
      GET:
        root_uri: '/getFile'
      PUT:
        root_uri: '/storeFile'
    *** FileHash.yml ***

=head1 DESCRIPTION

This is an attempt at solving a problem with hosting millions
of static files.  It should be straight forward enough to take
a suite of n servers and store x files across them.

It is assumed that each bucket is publically accessible and that

lib/Apache2/FileHash/PUT.pm  view on Meta::CPAN

package Apache2::FileHash::PUT;

use strict;
use warnings;

use Carp;
use Digest::MD5;
use Math::BigInt;
use File::Temp;
use File::Copy;

lib/Apache2/FileHash/PUT.pm  view on Meta::CPAN

use Math::BigInt;

use APR::Brigade ();
use APR::Bucket ();
use Apache2::Const -compile => qw(MODE_READBYTES);
use APR::Const -compile => qw(SUCCESS BLOCK_READ);

use MIME::Base64;
use Apache2::FileHash;

use constant METHOD => "PUT";

our $Config = {
    METHOD => {
        re_path => qr(^/storeFile/(.*)),
    },
};

sub handler
{
    my $r = shift;

lib/Apache2/FileHash/PUT.pm  view on Meta::CPAN


    $r->handler("perl-script");
    $r->push_handlers(PerlResponseHandler => \&file_handler);

    my $uri = $r->uri();
    my $path = "";
    if ($uri =~ m#$Config->{METHOD}{re_path}#) {
        $path = $1;
    }

    # First PUT
    unless (&Apache2::FileHash::inbucket($r, $path)) {
        my $filename = &Apache2::FileHash::hashing_function($r, $path);
        my $netloc = &Apache2::FileHash::netloc($r, $filename); # need netloc_hashed and netloc_uri

        my $bucket = &Apache2::FileHash::getbucket($r, $filename);

        my $location = $bucket->{location};
        my $name = $bucket->{name};
        my $method = $bucket->{method};
        my $port = $bucket->{port};

startup.pl  view on Meta::CPAN


use strict;
use warnings;

use lib qw(/opt/mod_perl);
use lib qw(/opt/mod_perl/lib);
use lib qw(/opt/Apache2);
use lib qw(/opt/Apache2/FileHash);

use Apache2::FileHash;
use Apache2::FileHash::PUT;
use Apache2::FileHash::GET;

use MIME::Types;

my @array = ();
foreach my $dir (@INC) {
    my $file = "$dir/$Apache2::FileHash::ConfigFile";
    eval {
        @array = &YAML::Tiny::LoadFile($file) or die("LoadFile($YAML::Tiny::errstr)");
    };



( run in 0.634 second using v1.01-cache-2.11-cpan-c6e0e5ac2a7 )