Amazon-S3-Thin

 view release on metacpan or  search on metacpan

t/02_signer_v2.t  view on Meta::CPAN

    my $sig = $signer->calculate_signature($verb, $path, $hdr);
    is $sig, 'lx3byBScXR6KzyMaifNkardMwNk=', "puppy delete (DELETE)";
}

{
    diag "test Amazon example upload";

    my $verb           = "PUT";
    my $date           = "Tue, 27 Mar 2007 21:06:08 +0000";
# TODO: ports should be stripped from the path for signing
#    my $path           = "static.johnsmith.net:8080/db-backup.dat.gz";
    my $path           = "static.johnsmith.net/db-backup.dat.gz";
    my $user_agent     = "curl/7.15.5";
    my $x_amz_acl      = "public-read";
    my $content_type   = "application/x-download";
    my $content_md5    = "4gJE4saaMU4BqNR0kLY+lw==";
    my @x_amz_meta_reviewed_by = ('joe@johnsmith.net', 'jane@johnsmith.net');
    my $x_amz_meta_filechecksum = '0x02661779';
    my $x_amz_meta_checksum_algorithm = 'crc32';
    my $content_disposition = "attachment; filename=database.dat";
    my $content_encoding = "gzip";
    my $content_length   = 5913339;

    my $string_to_sign = "PUT\n4gJE4saaMU4BqNR0kLY+lw==\napplication/x-download\nTue, 27 Mar 2007 21:06:08 +0000\nx-amz-acl:public-read\nx-amz-meta-checksumalgorithm:crc32\nx-amz-meta-filechecksum:0x02661779\nx-amz-meta-reviewedby:joe\@johnsmith.net,...

    my $signer = Amazon::S3::Thin::Signer::V2->new($credentials);
    my $hdr = HTTP::Headers->new;
    $hdr->header("Date", $date);
    $hdr->header("User-Agent", $user_agent);
    $hdr->header("x-amz-acl", $x_amz_acl);
    $hdr->header("content-type", $content_type);
    $hdr->header("Content-MD5", $content_md5);
    $hdr->header("X-Amz-Meta-ReviewedBy", join(',' => @x_amz_meta_reviewed_by));
    $hdr->header("X-Amz-Meta-FileChecksum", $x_amz_meta_filechecksum);



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