Furl::S3 - Furl based S3 client library.
use Furl::S3; my $s3 = Furl::S3->new( aws_access_key_id => '...', aws_secret_access_key => '...', ); $s3->create_bucket($bucket) or die $s3->error; my $res = $s3->list_objects($bucket) or die $s3->error; for my $obj(@{$res->{contents}}) { printf "%s\n", $obj->{key}; }
This module uses Furl lightweight HTTP client library and provides very simple interfaces to Amazon Simple Storage Service (Amazon S3)
for more details. see Amazon S3's developer guide and API References.
http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/
http://docs.amazonwebservices.com/AmazonS3/2006-03-01/API/
returns a new Furl::S3 object.
%args are below.
AWS Access Key ID
AWS Secret Access Key.
boolean flag. uses SSL connection or not.
S3 endpoint hostname. the default value is s3.amazonaws.com
other parmeters are passed to Furl->new. see Furl documents.
sends signed request. returns a Furl::Response object.
HTTP Request Method.
bucket name.
key of object.
request parameters.
HTTP headers.
arguments of $furl->request.
list all buckets. returns a HASH-REF
{ 'owner' => { 'id' => '...', 'display_name' => '..' }, 'buckets' => [ { 'creation_date' => '2010-11-30T00:00:00.000Z', 'name' => 'Your bucket name' }, #... ] }
create new bucket. returns a boolean value.
delete bucket. returns a boolean value.
list all objects in specified bucket. returna a HASH-REF
{ 'marker' => '', 'common_prefixes' => [], 'max_keys' => '10', 'contents' => [ { 'owner' => { 'id' => '..' 'display_name' => '...' }, 'etag' => 'xxx', 'storage_class' => 'STANDARD', 'last_modified' => '2010-12-01T00:00:00.000Z', 'size' => '10000', 'key' => 'foo/bar/baz.txt' }, #... ], 'name' => 'Your bucket name', 'delimiter' => '', 'is_truncated' => 1 }
\%params are below. see Amazon S3 documents for detail.
http://docs.amazonwebservices.com/AmazonS3/2006-03-01/API/index.html?RESTBucketGET.html
create new object. $content is passed to Furl. so you can specify scalar value or FileHandle object.
you can set any request headers. example is below.
open my $fh, '<', 'image.jpg' or die $!; $s3->create_object('you-bucket', 'public.jpg', $fh, { content_type => 'image/jpg', 'x-amz-acl' => 'public-read', }); close $fh;
get object.
\%furl_options are passed to Furl->request method. so you can use write_code or write_file to handle response.
returns a HASH-REF.
{ content => $content, content_length => '..', etag => '...', content_type => '...', last_modified => '...', 'x-amz-meta-foo' => 'metadata' }
get object and write to file. returns a boolean value.
get object's metadata. returns a HASH-REF
{ content_length => '..', etag => '...', content_type => '...', last_modified => '...', 'x-amz-meta-foo' => 'metadata' }
delete object. returns a boolean value.
copy object. return a boolean value.
Tomohiro Ikebe <ikebe {at} shebang.jp>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Furl::S3, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Furl::S3
CPAN shell
perl -MCPAN -e shell install Furl::S3
For more information on module installation, please visit the detailed CPAN module installation guide.