AWS-S3
view release on metacpan or search on metacpan
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/HTTPRequest.pm view on Meta::CPAN
use AWS::S3::Signer;
use HTTP::Headers;
use URI;
with 'AWS::S3::Roles::Bucket';
my $METADATA_PREFIX = 'x-amz-meta-';
my $AMAZON_HEADER_PREFIX = 'x-amz-';
enum 'HTTPMethod' => [qw( HEAD GET PUT POST DELETE )];
has 's3' => (
is => 'ro',
required => 1,
isa => 'AWS::S3',
);
has 'method' => (
is => 'ro',
required => 1,
lib/AWS/S3/Request/CreateBucket.pm view on Meta::CPAN
if ( $s->location && $s->location ne 'us-east-1' ) {
$xml = <<"XML";
<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<LocationConstraint>@{[ $s->location ]}</LocationConstraint>
</CreateBucketConfiguration>
XML
}
my $signer = AWS::S3::Signer->new(
s3 => $s->s3,
method => 'PUT',
uri => $s->protocol . '://' . $s->bucket . '.' . $s->endpoint . '/',
content_type => 'text/plain',
content_md5 => '',
content => \$xml,
);
return $s->_send_request(
$signer->method => $signer->uri => {
Authorization => $signer->auth_header,
Date => $signer->date,
lib/AWS/S3/Request/SetBucketAccessControl.pm view on Meta::CPAN
);
has '+_expect_nothing' => ( default => 1 );
sub request {
my $s = shift;
if ( $s->acl_short ) {
my $signer = AWS::S3::Signer->new(
s3 => $s->s3,
method => 'PUT',
uri => $s->protocol . '://' . $s->bucket . '.' . $s->endpoint . '/?acl',
headers => [ 'x-amz-acl' => $s->acl_short ]
);
return $s->_send_request(
$signer->method => $signer->uri => {
Authorization => $signer->auth_header,
Date => $signer->date,
'x-amz-acl' => $s->acl_short
},
$s->acl_xml
);
} elsif ( $s->acl_xml ) {
my $signer = AWS::S3::Signer->new(
s3 => $s->s3,
method => 'PUT',
uri => $s->protocol . '://' . $s->bucket . '.' . $s->endpoint . '/?acl',
content => \$s->acl_xml,
'content-type' => 'text/xml',
);
return $s->_send_request(
$signer->method => $signer->uri => {
Authorization => $signer->auth_header,
Date => $signer->date,
},
$s->acl_xml
lib/AWS/S3/Request/SetBucketPolicy.pm view on Meta::CPAN
# }
);
has '+_expect_nothing' => ( default => 1 );
sub request {
my $s = shift;
my $signer = AWS::S3::Signer->new(
s3 => $s->s3,
method => 'PUT',
uri => $s->_uri,
content => \$s->policy,
content_type => '',
content_md5 => '',
);
#warn "SetPolicy.string_to_sign(" . $signer->string_to_sign . ")";
$s->_send_request(
$signer->method => $signer->uri => {
Authorization => $signer->auth_header,
lib/AWS/S3/Request/SetFileContents.pm view on Meta::CPAN
$contents = $s->file->contents->();
} elsif ( ref( $s->file->contents ) eq 'SCALAR' ) {
$contents = $s->file->contents;
} # end if()
my %other_args = ();
$other_args{'x-amz-server-side-encryption'} = 'AES256' if $s->file->is_encrypted;
my $signer = AWS::S3::Signer->new(
s3 => $s->s3,
method => 'PUT',
uri => $s->protocol . '://' . $s->bucket . '.' . $s->endpoint . '/' . $s->file->key,
content_type => $s->content_type,
content => $contents,
headers => [ 'x-amz-storage-class', $s->file->storage_class ],
);
$s->_send_request(
$signer->method => $signer->uri => {
Authorization => $signer->auth_header,
Date => $signer->date,
'content-type' => $s->content_type,
lib/AWS/S3/Signer.pm view on Meta::CPAN
use MooseX::Types::URI qw(Uri);
has 's3' => (
is => 'ro',
isa => 'AWS::S3',
required => 1,
);
has 'method' => (
is => 'ro',
isa => enum([qw/ HEAD GET PUT POST DELETE /]),
required => 1,
);
has 'bucket_name' => (
is => 'ro',
isa => 'Str',
required => 1,
lazy => 1,
default => sub {
my $s = shift;
lib/AWS/S3/Signer/V4.pm view on Meta::CPAN
sub signed_url {
my $self = shift;
my ( $arg1, $expires, $verb ) = @_;
my ( $request, $uri );
$verb ||= 'GET';
$verb = uc($verb);
my $incorrect_verbs = {
POST => 1,
PUT => 1
};
if ( exists( $incorrect_verbs->{$verb} ) ) {
die "Use AWS::S3::Signer::V4->sign sub for $verb method";
}
if ( ref $arg1 && UNIVERSAL::isa( $arg1, 'HTTP::Request' ) ) {
$request = $arg1;
$uri = $request->uri;
my $content = $request->content;
subtest 'create bucket strange temporary redirect' => sub {
plan tests => 8; # make sure all tests in here get run
my $i = 1;
local *LWP::UserAgent::Determined::request = sub {
my ( undef, $req ) = @_;
if ( $i == 1 ) {
# first PUT request, send a forward
is( $req->method, 'PUT', 'bucket creation with PUT request' );
is( $req->uri->as_string, 'http://bar.bad.hostname./', '... and with correct URI' );
$i++;
return HTTP::Response->new(
307,
'TEMPORARY REDIRECT',
[ Location => 'http://example.org' ],
'<fake>TemporaryRedirect</fake>'
);
}
elsif ( $i == 2 ) {
# the PUT is sent again, but to the forwarded location
is( $req->method, 'PUT', 'redirected and second PUT request' );
is( $req->uri->as_string, 'http://example.org', '... and to the correct URI' );
$i++;
return Mocked::HTTP::Response->new( 200, q{} );
}
else {
# there is a call to ->bucket, which does ->buckets, which is empty.
is( $req->method, 'GET', '->buckets with GET' );
is( $req->uri->as_string, 'http://bad.hostname./', '... and with correct URI' );
( run in 0.418 second using v1.01-cache-2.11-cpan-4e96b696675 )