AWS-S3
view release on metacpan or search on metacpan
- File's S3 was a weak ref, which caused problems. No longer...
0.020 2011-12-21
- Updated to be compatible with VSO 0.21
0.019 2011-12-14
- Bucket's S3 was a weak ref, which caused problems sometimes. Not anymore...
we'll see if that fixes it.
0.018 2011-12-13
- Thanks to ukautz++ (Ulrich Kautz) for adding the ability to set the content-type
of files stored in S3.
- He even updated the POD to show how to set the content-type (via 'contenttype').
0.017 2011-12-11
- Fixed broken META.yml (again)
0.016 2011-12-10
- Fixed broken META.yml
0.015 2011-12-10
- Migrated to github.
- Added repository url to meta.
lib/AWS/S3/Bucket.pm view on Meta::CPAN
my $parser = $s->_get_property( $type, key => $key )
or return;
my $res = $parser->response;
confess "Cannot get file: ", $res->as_string, " " unless $res->is_success;
return AWS::S3::File->new(
bucket => $s,
key => $key || undef,
size => $res->header( 'content-length' ) || 0,
contenttype => $res->header( 'content-type' ) || 'application/octet-stream',
etag => $res->header( 'etag' ) || undef,
lastmodified => $res->header( 'last-modified' ) || undef,
is_encrypted => ( $res->header( 'x-amz-server-side-encryption' ) || '' ) eq 'AES256' ? 1 : 0,
);
} # end file()
sub add_file {
my ( $s, %args ) = @_;
my $file = AWS::S3::File->new(
lib/AWS/S3/HTTPRequest.pm view on Meta::CPAN
method => $method,
uri => $uri,
content => $content ? \$content : undef,
headers => [ $headers->flatten ],
);
$headers->header( 'Authorization' => $signer->auth_header );
$headers->header( 'Date' => $signer->date );
$headers->header( 'Host' => URI->new( $uri )->host );
$headers->header( 'content-length' => $signer->content_length ) if $content;
$headers->header( 'content-type' => $signer->content_type ) if $content;
my $request = HTTP::Request->new( $method, $uri, $headers, $content );
return $request;
} # end http_request()
__PACKAGE__->meta->make_immutable;
lib/AWS/S3/Request/CreateBucket.pm view on Meta::CPAN
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,
'content-type' => 'text/plain',
},
$xml
);
}
__PACKAGE__->meta->make_immutable;
lib/AWS/S3/Request/SetBucketAccessControl.pm view on Meta::CPAN
'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
);
} # end if()
} # end request()
lib/AWS/S3/Request/SetFileContents.pm view on Meta::CPAN
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,
'content-md5' => $signer->content_md5,
'x-amz-storage-class' => $s->file->storage_class,
},
$$contents
);
} # end request()
__PACKAGE__->meta->make_immutable;
t/aws/s3/http_request.t view on Meta::CPAN
s3 => $s3,
method => 'POST',
path => '/bar/baz',
content => 'Hello World!'
),
'AWS::S3::HTTPRequest'
);
isa_ok( my $http_request_with_content = $request_with_content->http_request, 'HTTP::Request' );
my $header = $http_request_with_content->headers;
is( $header->header( 'content-type' ), 'text/plain', '... and content-type got set' );
is( $header->header( 'content-length' ), 12, '... and content-length got set' );
is( $header->header( 'host' ), 's3.baz.com', '... and host got set' );
done_testing();
t/aws/s3/signer/v4.t view on Meta::CPAN
is( $request->method, 'POST', 'request method correct' );
is( $request->header('Host'), 'iam.amazonaws.com', 'host correct' );
is( $request->header('X-Amz-Date'), '20140101T060000Z', 'timestamp correct' );
is(
$request->content,
'Action=ListUsers&Version=2010-05-08',
'payload correct'
);
is(
$request->header('Authorization'),
'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20140101/us-east-1/iam/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature=0233049369ae675cea7616efa5d2e5216c37a4b1496a36595f32181f078e3549',
'signature correct'
);
$request = GET( 'https://iam.amazonaws.com?Action=ListUsers&Version=2010-05-08',
Date => '1 January 2014 01:00:00 -0500' );
my $expected =
'https://iam.amazonaws.com?Action=ListUsers&Version=2010-05-08&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIDEXAMPLE%2F20140101%2Fus-east-1%2Fiam%2Faws4_request&X-Amz-Date=20140101T060000Z&X-Amz-SignedHeaders=host&X-Amz-Signature=9d0b832ec5c5...
is( $signer->signed_url($request),
t/aws/s3/signer/v4.t view on Meta::CPAN
Date => '1 January 2014 01:00:00 -0500'
);
is( $signer->signed_url($request), $expected, 'domain bucket url' );
$request = POST('https://cognito-identity.us-east-1.amazonaws.com',
Date => '1 January 2014 01:00:00 -0500');
$signer->sign($request);
is($request->header('Authorization'),'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20140101/us-east-1/cognito-identity/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature=047c9335c6a34448efc59c2a1813711602e208dcb42ae95cd3b88...
exit 0;
( run in 4.195 seconds using v1.01-cache-2.11-cpan-524268b4103 )