view release on metacpan or search on metacpan
lib/AWS/S3.pm view on Meta::CPAN
See L<AWS::S3::Bucket> for details on how to use buckets (and access their files).
=head1 ENVIRONMENT VARIABLES
=head2 AWS_S3_DEBUG
If set, will print out debugging information to C<STDERR>.
=head1 SEE ALSO
L<The Amazon S3 API Documentation|http://docs.amazonwebservices.com/AmazonS3/latest/API/>
L<AWS::S3::Bucket>
L<AWS::S3::File>
L<AWS::S3::FileIterator>
L<AWS::S3::Owner>
=head1 AUTHOR
lib/AWS/S3/Bucket.pm view on Meta::CPAN
#warn $response->response->as_string;
if ( my $msg = $response->friendly_error() ) {
die $msg;
} # end if()
$self->_clear_policy;
}
);
# XXX: Not tested.
sub enable_cloudfront_distribution {
my ( $s, $cloudfront_dist ) = @_;
$cloudfront_dist->isa( 'AWS::CloudFront::Distribution' )
or die "Usage: enable_cloudfront_distribution( <AWS::CloudFront::Distribution object> )";
my $ident = $cloudfront_dist->cf->create_origin_access_identity( Comment => "Access to s3://" . $s->name, );
$s->policy( <<"JSON");
{
"Version":"2008-10-17",
lib/AWS/S3/Bucket.pm view on Meta::CPAN
String. Returned from the S3 service itself.
Read-only.
=head2 acl
String. Returns XML string.
Read-only.
See also L<PUT Bucket ACL|http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?RESTBucketPUTacl.html>
=head2 location_constraint
String. Read-only.
=over 4
=item * EU
=item * us-west-1
lib/AWS/S3/Bucket.pm view on Meta::CPAN
=item * us-west-2
=item * ap-southeast-1
=item * ap-northeast-1
=back
The default value is undef which means 'US'.
See also L<PUT Bucket|http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?RESTBucketPUT.html>
=head2 policy
Read-only. String of JSON.
Looks something like this:
{
"Version":"2008-10-17",
"Id":"aaaa-bbbb-cccc-dddd",
lib/AWS/S3/Bucket.pm view on Meta::CPAN
"Sid":"1",
"Principal" : {
"AWS":["1-22-333-4444","3-55-678-9100"]
},
"Action":["s3:*"],
"Resource":"arn:aws:s3:::bucket/*",
}
]
}
See also L<GET Bucket Policy|http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?RESTBucketGETpolicy.html>
=head1 PUBLIC METHODS
=head2 files( page_size => $size, page_number => $number, [[marker => $marker,] pattern => qr/$pattern/ ] )
Returns a L<AWS::S3::FileIterator> object with the supplied arguments.
Use the L<AWS::S3::FileIterator> to page through your results.
=head2 file( $key )
lib/AWS/S3/Bucket.pm view on Meta::CPAN
# Reset to page 1:
$iter->page_number( 1 );
warn "Deleted $deleted files so far\n";
}# end while()
# NOW you can delete your bucket (if you want) because it's empty:
$bucket->delete;
=head1 SEE ALSO
L<The Amazon S3 API Documentation|http://docs.amazonwebservices.com/AmazonS3/latest/API/>
L<AWS::S3::Bucket>
L<AWS::S3::File>
L<AWS::S3::FileIterator>
L<AWS::S3::Owner>
=cut
lib/AWS/S3/File.pm view on Meta::CPAN
=head2 signed_url( $expiry_time )
Will return a signed URL for public access to the file. $expiry_time should be a
Unix seconds since epoch, and will default to now + 1 hour is not passed.
Note that the Signature parameter value will be URI encoded to prevent reserved
characters (+, =, etc) causing a bad request.
=head1 SEE ALSO
L<The Amazon S3 API Documentation|http://docs.amazonwebservices.com/AmazonS3/latest/API/>
L<AWS::S3>
L<AWS::S3::Bucket>
L<AWS::S3::FileIterator>
L<AWS::S3::Owner>
=cut
lib/AWS/S3/FileIterator.pm view on Meta::CPAN
=head1 PUBLIC METHODS
=head2 next_page()
Returns the next page of results as an array in list context or arrayref in scalar context.
Increments C<page_number> by one.
=head1 SEE ALSO
L<The Amazon S3 API Documentation|http://docs.amazonwebservices.com/AmazonS3/latest/API/>
L<AWS::S3>
L<AWS::S3::Bucket>
L<AWS::S3::File>
L<AWS::S3::Owner>
L<Iterator::Paged> - on which this class is built.
lib/AWS/S3/Roles/Bucket.pm view on Meta::CPAN
if ( $path =~ m{^([^/?]+)(.*)} && $s->is_dns_bucket( $1 ) ) {
$uri = "$protocol://$1.$endpoint$2";
} # end if()
return $uri;
}
sub is_dns_bucket {
my ( $s,$bucket ) = @_;
# https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
return 0 if ( length( $bucket ) < 3 or length( $bucket ) > 63 );
return 0 if $bucket =~ /^(?:\d{1,3}\.){3}\d{1,3}$/;
# DNS bucket names can contain lowercase letters, numbers, and hyphens
# so anything outside this range we say isn't a valid DNS bucket
return $bucket =~ /[^a-z0-9-\.]/ ? 0 : 1;
}
1;
lib/AWS/S3/Signer/V4.pm view on Meta::CPAN
my $uri = URI->new('https://iam.amazonaws.com');
$uri->query_form(Action=>'ListUsers',
Version=>'2010-05-08');
my $url = $signer->signed_url($uri); # This gives a signed URL that can be fetched by a browser
my $response = $ua->get($url);
=head1 DESCRIPTION
This module implement's Amazon Web Service's Signature version 4
(http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html).
=head1 METHODS
=over 4
=item $signer = AWS::S3::Signer::V4->new(-access_key => $account_id,-secret_key => $private_key);
Create a signing object using your AWS account ID and secret key. You
may also use the temporary security tokens received from Amazon's STS
service, either by passing the access and secret keys derived from the
lib/AWS/S3/Signer/V4.pm view on Meta::CPAN
$uri->query_param( 'X-Amz-SignedHeaders' => 'host' );
# If there was a security token passed, we need to supply it as part of the authorization
# because AWS requires it to validate IAM Role temporary credentials.
if ( defined( $self->{security_token} ) ) {
$uri->query_param( 'X-Amz-Security-Token' => $self->{security_token} );
}
# Since we're providing auth via query parameters, we need to include UNSIGNED-PAYLOAD
# http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
# it seems to only be needed for S3.
if ( $scope =~ /\/s3\/aws4_request$/ ) {
$self->_sign( $request, undef, 'UNSIGNED-PAYLOAD' );
}
else {
$self->_sign($request);
}
my ( $algorithm, $credential, $signedheaders, $signature ) =
lib/AWS/S3/Signer/V4.pm view on Meta::CPAN
}
sub parse_host {
my $self = shift;
my $host = shift;
my $region = shift;
# this entire thing should probably refactored into its own
# distribution, a la https://github.com/zirkelc/amazon-s3-url
# https://docs.aws.amazon.com/prescriptive-guidance/latest/defining-bucket-names-data-lakes/faq.html
# Only lowercase letters, numbers, dashes, and dots are allowed in S3 bucket names.
# Bucket names must be three to 63 characters in length,
# must begin and end with a number or letter,
# and cannot be in an IP address format.
my $bucket_re = '[a-z0-9][a-z0-9\-\.]{1,61}[a-z0-9]';
my $domain_re = 'amazonaws\.com';
my $region_re = '(?:af|ap|ca|eu|il|me|mx|sa|us)-[a-z]+-\d';
my ( $service, $url_style );