AWS-S3

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.13 2017-02-06
  - Add documentation for parameter 'prefix' for AWS::S3::FileIterator
  - Add test coverage (GH #8, thanks to simbabque for these changes)
  - Fix over encoding of characters in path (GH #6)

0.12 2016-03-07
  - Fix DNS bucket name checking for non-valid DNS bucket nams (GH #4)
  - Fix URI escaping for filenames to avoid infinite loop on spaces (GH #5)

0.11 2015-08-31
  - Fix signed_url to URI escape the Signature param value (GH #3)

0.10 2015-06-23
  - dist changes related to kwalitee (no functional changes)

0.051 2015-05-23
  - default size to 0 when not set in content-length (GH #1)

0.050 2014-10-23
  New maintainer leejo
  - Add lib/AWS/S3/Request/GetPreSignedUrl.pm to MANIFEST

lib/AWS/S3/Request/GetPreSignedUrl.pm  view on Meta::CPAN


package AWS::S3::Request::GetPreSignedUrl;
use Moose;

use AWS::S3::Signer;
use URI::Escape qw(uri_escape);

with 'AWS::S3::Roles::Request';

has 'bucket' => ( is => 'ro', isa => 'Str', required => 1 );
has 'key' => ( is => 'ro', isa => 'Str', required => 1 );
has 'expires' => ( is => 'ro', isa => 'Int', required => 1 );

sub request {
    my $s = shift;

lib/AWS/S3/Request/ListBucket.pm  view on Meta::CPAN


package AWS::S3::Request::ListBucket;

use Moose;
use AWS::S3::Signer;
use URI::Escape qw/ uri_escape /;

with 'AWS::S3::Roles::Request';
with 'AWS::S3::Roles::Bucket';

has 'bucket' => (
    is       => 'ro',
    isa      => 'Str',
    required => 1,
);

lib/AWS/S3/Request/ListBucket.pm  view on Meta::CPAN

    required => 0,
);

has '+_expect_nothing' => ( default => 0 );

sub request {
    my $s = shift;

    my @params = ();
    push @params, 'max-keys=' . $s->max_keys;
    push @params, 'marker=' . uri_escape( $s->marker ) if $s->marker;
    push @params, 'prefix=' . $s->prefix if $s->prefix;
    push @params, 'delimiter=' . $s->delimiter if $s->delimiter;

    my $uri = $s->bucket_uri;

    my $signer = AWS::S3::Signer->new(
        s3     => $s->s3,
        method => 'GET',
        uri    => $uri . '/' . ( @params ? '?' . join( '&', @params ) : '' ),
    );

lib/AWS/S3/Roles/Request.pm  view on Meta::CPAN

package AWS::S3::Roles::Request;
use Moose::Role;
use HTTP::Request;
use AWS::S3::ResponseParser;
use MooseX::Types::URI qw(Uri);
use URI::Escape qw/ uri_escape /;
use AWS::S3::Signer::V4;

has 's3' => (
    is       => 'ro',
    isa      => 'AWS::S3',
    required => 1,
);

has 'type' => (
    is       => 'ro',

lib/AWS/S3/Roles/Request.pm  view on Meta::CPAN

        my $self = shift;
        my $m = $self->meta;

        my $uri = URI->new(
            $self->protocol . '://'
            . ( $m->has_attribute('bucket') ? $self->bucket . '.' : '' )
            . $self->endpoint
            . '/'
        );

		# note we add some extra exceptions to uri_escape to prevent
		# encoding of things like "/", ":", "="
        if ( $m->has_attribute('key') ) {
            my $escaped_path = uri_escape( $self->key,"^A-Za-z0-9\-\._~\/:=" );

            # if we have a leading slash in the key name we need to add *another*
            # slash in the call to ->path to ensure it is retained
            if ( $escaped_path =~ m!^/! && $self->s3->honor_leading_slashes ) {
                $uri->path( '/'.$escaped_path )
            } else {
                $uri->path( $escaped_path )
            }
        }

        $uri->query_keywords( $self->_subresource )
          if $m->has_attribute('_subresource');

        $uri;
    }
);

lib/AWS/S3/Signer/V4.pm  view on Meta::CPAN

    # canonicalize query string

    # in the case of the S3 api, but its still expected to be part of a
    # canonical request.
    if (scalar(@params) == 0 && defined($uri->query) && $uri->query ne '') {
        push @params, ($uri->query, '');
    }

    my %canonical;
    while ( my ( $key, $value ) = splice( @params, 0, 2 ) ) {
        $key   = uri_escape($key);
        $value = uri_escape($value);
        push @{ $canonical{$key} }, $value;
    }
    my $canonical_query_string = join '&', map {
        my $key = $_;
        map { "$key=$_" } sort @{ $canonical{$key} }
    } sort keys %canonical;

    # canonicalize the request headers
    my ( @canonical, %signed_fields );
    for my $header ( sort map { lc } $headers->header_field_names ) {

t/aws/s3/file.t  view on Meta::CPAN

sub code           { 200 }
sub is_success     { 1 }
sub header         { $_[1] =~ /content-length/i ? 1 : 'header' }

1;

package main;

use Test::More;
use Test::Deep;
use URI::Escape qw/ uri_escape /;

use Carp 'confess';
$SIG{__DIE__} = \&confess;

use_ok('AWS::S3');

note( "construction" );

foreach my $leading_slashes ( 0,1 ) {
my $s3 = AWS::S3->new(



( run in 0.524 second using v1.01-cache-2.11-cpan-b888b73be4d )