view release on metacpan or search on metacpan
0.60 Sun May 11 23:36:38 BST 2013
- Moose enum fixes (patch by Tom Hukins)
- Support for reduced redundancy (patch by Aaron Crane)
- README file name fix (patch by Jay Hannah)
- Fixed s3cl synopsis for sync_up (patch by perlpong)
0.59 Sat Mar 17 09:36:38 GMT 2013
- Added support for security token authentication (patch by Miquel Ruiz)
0.58 Wed Nov 28 16:22:42 GMT 2012
- Added support for multi-part upload and multiple objects deletion (patch
by Robert B. Clarke)
0.57 Sun Sep 16 22:38:38 BST 2012
- Added support for Content-disposition (initial patch by Michele Beltrame)
- Added sync_up option to s3cl (patch by Leo Lapworth)
- Dist::Zilla tidying
0.56 Sun Dec 18 22:22:32 GMT 2011
- Spelling error (RT #69817, patch from Fabrizio Regalli)
- Added use_ok tests (RT #72856, suggested by Gregor Herrmann)
bin/s3cl_ae view on Meta::CPAN
foreach my $f (@files) {
my $file = file($f);
my ( $mediatype, $encoding ) = by_suffix $file->basename();
# Assume plain text unless we can work i
unless ($mediatype) {
if ( -T $file ) {
$mediatype = 'text/plain';
} else {
$progress++;
$progress->message("$f - NOT uploading");
warn "Not uploading: $file";
warn "Unknown mime type, submit patch to MIME::Types";
next;
}
}
my $content = $file->slurp();
my $md5 = md5_hex($content);
my $key = $file->stringify;
$key =~ s/$dir_string//; # remove our local path for the dir
bin/s3cl_ae view on Meta::CPAN
) or die $s3->err . ": " . $s3->errstr;
if ($acl_short) {
$bucket->set_acl(
{ key => $key,
acl_short => $acl_short,
}
) || die $s3->err . ": " . $s3->errstr;
}
$progress->message("$key - $mediatype - uploaded");
$progress++;
}
}
sub cp {
my $dest = $args{dest_or_source} || '';
helper("No destination supplied") if $dest eq '';
bin/s3cl_ae view on Meta::CPAN
# data transferred between Amazon EC2 and Amazon S3-Europe,
# which will be charged at regular rates.
=item B<sync_up>
s3cl_ae sync_up [--acl_short=public-read] /path/ <bucket>:[prefix]
Upload all the files below /path/ to S3, with an optional
prefix at the start of the key name. The existing S3 files and
meta data are fetched from S3 and the md5 (etag) is compaired to
what is on the local disk, files are not upload if the content has
not changed.
Use --acl_short to set access control, options from
L<Net::Amazon::S3::Bucket#set_acl> this is only applied when the
file is uploaded.
Each files content-type is worked out using L<MIME::Types>,
if this does not match 'text/plain' is used for ASCII text files,
otherwise a warning is issued and the file is NOT uploaded.
Currently this does NOT remove old files from S3, and if there is
any change to a file then the entire file will be reuploaded.
=item B<rm>
s3cl_ae rm <bucket>:<key>
Remove a key(file) from the bucket, removing a non-existent file
is not classed as an error. Once removed the key (file) can not
be restored - so use with care!
=back
lib/AnyEvent/Net/Amazon/S3/Client/Object.pm view on Meta::CPAN
our $VERSION = 'v0.04.0.80'; # VERSION
use strict;
use warnings;
# TODO: _content_sub might become more async manner?
# NOTE: exists and delete have HIGH risk.
use Module::AnyEvent::Helper::Filter -as => __PACKAGE__, -target => 'Net::Amazon::S3::Client::Object',
-transformer => 'Net::Amazon::S3::Client::Object',
-translate_func => [qw(exists _get get get_decoded get_filename _put put put_filename delete
initiate_multipart_upload complete_multipart_upload abort_multipart_upload put_part)],
-replace_func => [qw(_send_request_raw _send_request _send_request_xpc)]
;
1;
__END__
=pod
=encoding UTF-8
lib/AnyEvent/Net/Amazon/S3/Client/Object.pm view on Meta::CPAN
# return the URI of a publically-accessible object
my $uri = $object->uri;
# to store a new object with server-side encryption enabled
my $object = $bucket->object(
key => 'my secret',
encryption => 'AES256',
);
$object->put('this data will be stored using encryption.');
# upload a file
my $object = $bucket->object(
key => 'images/my_hat.jpg',
content_type => 'image/jpeg',
);
$object->put_filename('hat.jpg');
# upload a file if you already know its md5_hex and size
my $object = $bucket->object(
key => 'images/my_hat.jpg',
content_type => 'image/jpeg',
etag => $md5_hex,
size => $size,
);
$object->put_filename('hat.jpg');
# download the value of the object into a file
my $object = $bucket->object( key => 'images/my_hat.jpg' );
lib/AnyEvent/Net/Amazon/S3/Client/Object.pm view on Meta::CPAN
=item get_async
=item get_decoded_async
=item get_filename_async
=item put_async
=item put_filename_async
=item complete_multipart_upload_async
=item initiate_multipart_upload_async
=item abort_multipart_upload_async
=item put_part_async
=back
=for Pod::Coverage list_parts
query_string_authentication_uri
uri
get_callback
lib/AnyEvent/Net/Amazon/S3/Request/AbortMultipartUpload.pm view on Meta::CPAN
package AnyEvent::Net::Amazon::S3::Request::AbortMultipartUpload;
# ABSTRACT: An internal class to abort a multipart upload
our $VERSION = 'v0.04.0.80'; # VERSION
use strict;
use warnings;
use Module::AnyEvent::Helper::Filter -as => __PACKAGE__,
-target => substr(__PACKAGE__, 10),
-transformer => 'Net::Amazon::S3';
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AnyEvent::Net::Amazon::S3::Request::AbortMultipartUpload - An internal class to abort a multipart upload
=head1 VERSION
version v0.04.0.80
=head1 SYNOPSIS
my $http_request = AnyEvent::Net::Amazon::S3::Request::AbortMultipartUpload->new(
s3 => $s3,
bucket => $bucket,
key => $key,
upload_id => $upload_id,
)->http_request;
=head1 DESCRIPTION
This module is the same as L<Net::Amazon::S3::Request::AbortMultipartUpload>, except for its name.
=for test_synopsis no strict 'vars';
=head1 METHODS
lib/AnyEvent/Net/Amazon/S3/Request/CompleteMultipartUpload.pm view on Meta::CPAN
package AnyEvent::Net::Amazon::S3::Request::CompleteMultipartUpload;
# ABSTRACT: An internal class to complete a multipart upload
our $VERSION = 'v0.04.0.80'; # VERSION
use strict;
use warnings;
use Module::AnyEvent::Helper::Filter -as => __PACKAGE__,
-target => substr(__PACKAGE__, 10),
-transformer => 'Net::Amazon::S3';
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AnyEvent::Net::Amazon::S3::Request::CompleteMultipartUpload - An internal class to complete a multipart upload
=head1 VERSION
version v0.04.0.80
=head1 SYNOPSIS
my $http_request = AnyEvent::Net::Amazon::S3::Request::CompleteMultipartUpload->new(
s3 => $s3,
bucket => $bucket,
lib/AnyEvent/Net/Amazon/S3/Request/InitiateMultipartUpload.pm view on Meta::CPAN
package AnyEvent::Net::Amazon::S3::Request::InitiateMultipartUpload;
# ABSTRACT: An internal class to begin a multipart upload
our $VERSION = 'v0.04.0.80'; # VERSION
use strict;
use warnings;
use Module::AnyEvent::Helper::Filter -as => __PACKAGE__,
-target => substr(__PACKAGE__, 10),
-transformer => 'Net::Amazon::S3';
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AnyEvent::Net::Amazon::S3::Request::InitiateMultipartUpload - An internal class to begin a multipart upload
=head1 VERSION
version v0.04.0.80
=head1 SYNOPSIS
my $http_request = AnyEvent::Net::Amazon::S3::Request::InitiateMultipartUpload->new(
s3 => $s3,
bucket => $bucket,
lib/AnyEvent/Net/Amazon/S3/Request/ListParts.pm view on Meta::CPAN
package AnyEvent::Net::Amazon::S3::Request::ListParts;
# ABSTRACT: List the parts in a multipart upload.
our $VERSION = 'v0.04.0.80'; # VERSION
use strict;
use warnings;
use Module::AnyEvent::Helper::Filter -as => __PACKAGE__,
-target => substr(__PACKAGE__, 10),
-transformer => 'Net::Amazon::S3';
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AnyEvent::Net::Amazon::S3::Request::ListParts - List the parts in a multipart upload.
=head1 VERSION
version v0.04.0.80
=head1 SYNOPSIS
my $http_request = AnyEvent::Net::Amazon::S3::Request::ListParts->new(
s3 => $s3,
bucket => $bucket,
key => $key,
upload_id => $upload_id,
acl_short => $acl_short,
)->http_request;
=head1 DESCRIPTION
This module is the same as L<Net::Amazon::S3::Request::ListParts>, except for its name.
=for test_synopsis no strict 'vars';
=head1 METHODS
lib/AnyEvent/Net/Amazon/S3/Request/PutPart.pm view on Meta::CPAN
package AnyEvent::Net::Amazon::S3::Request::PutPart;
# ABSTRACT: An internal class to put part of a multipart upload
our $VERSION = 'v0.04.0.80'; # VERSION
use strict;
use warnings;
use Module::AnyEvent::Helper::Filter -as => __PACKAGE__,
-target => substr(__PACKAGE__, 10),
-transformer => 'Net::Amazon::S3';
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AnyEvent::Net::Amazon::S3::Request::PutPart - An internal class to put part of a multipart upload
=head1 VERSION
version v0.04.0.80
=head1 SYNOPSIS
my $http_request = AnyEvent::Net::Amazon::S3::Request::PutPart->new(
s3 => $s3,
bucket => $bucket,
key => $key,
value => $value,
acl_short => $acl_short,
headers => $conf,
part_number => $part_number,
upload_id => $upload_id
)->http_request;
=head1 DESCRIPTION
This module is the same as L<Net::Amazon::S3::Request::PutPart>, except for its name.
=for test_synopsis no strict 'vars';
=head1 METHODS
t/02client.t view on Meta::CPAN
$object->expires('2037-01-01');
is( get( $object->query_string_authentication_uri() ),
'this is the value',
'newly created object can be fetch by authentication uri'
);
$object->delete;
# upload a public object
$object = $bucket->object(
key => 'this is the public key',
acl_short => 'public-read',
content_type => 'text/plain',
content_encoding => 'identity',
expires => '2001-02-03',
);
$object->put('this is the public value');
is( get( $object->uri ),
'this is the public value',
t/02client.t view on Meta::CPAN
$object->expires->epoch,
'newly created public object has the right expires' );
$object->delete;
# delete a non-existant object
$object = $bucket->object( key => 'not here' );
throws_ok { $object->get } qr/NoSuchKey/,
'getting non-existant object throws exception';
# upload a file with put_filename
$object = $bucket->object( key => 'the readme' );
$object->put_filename('README');
@objects = ();
$stream = $bucket->list;
until ( $stream->is_done ) {
foreach my $object ( $stream->items ) {
push @objects, $object;
}
}
is( @objects, 1, 'have newly uploaded object' );
is( $objects[0]->key, 'the readme',
'newly uploaded object has the right key' );
is( $objects[0]->etag, $readme_md5hex,
'newly uploaded object has the right etag' );
is( $objects[0]->size, $readme_size,
'newly created object has the right size' );
ok( $objects[0]->last_modified, 'newly created object has a last modified' );
$object->delete;
# upload a public object with put_filename
$object = $bucket->object(
key => 'the public readme',
acl_short => 'public-read'
);
$object->put_filename('README');
is( length( get( $object->uri ) ),
$readme_size, 'newly uploaded public object has the right size' );
$object->delete;
# upload a file with put_filename with known md5hex size and AES256 encryption
$object = $bucket->object(
key => 'the new readme',
etag => $readme_md5hex,
size => $readme_size,
encryption => 'AES256'
);
$object->put_filename('README');
@objects = ();
$stream = $bucket->list;
until ( $stream->is_done ) {
foreach my $object ( $stream->items ) {
push @objects, $object;
}
}
is( @objects, 1, 'have newly uploaded object' );
is( $objects[0]->key,
'the new readme',
'newly uploaded object has the right key'
);
is( $objects[0]->etag, $readme_md5hex,
'newly uploaded object has the right etag' );
is( $objects[0]->size, $readme_size,
'newly created object has the right size' );
ok( $objects[0]->last_modified, 'newly created object has a last modified' );
# download an object with get_filename
my $tmp_fh = File::Temp->new();
$object->get_filename($tmp_fh->filename);
is( stat($tmp_fh->filename)->size, $readme_size, 'download has right size' );
is( file_md5_hex($tmp_fh->filename), $readme_md5hex, 'download has right etag' );
$object->delete;
# upload a public object with put_filename with known md5hex and size
$object = $bucket->object(
key => 'the new public readme',
etag => $readme_md5hex,
size => $readme_size,
acl_short => 'public-read'
);
$object->put_filename( 'README', $readme_md5hex, $readme_size );
is( length( get( $object->uri ) ),
$readme_size, 'newly uploaded public object has the right size' );
$object->delete;
{
# upload an object using multipart upload and then abort it
$object = $bucket->object(
key => 'new multipart file soon to be aborted',
acl_short => 'public-read'
);
my $upload_id;
ok(
$upload_id = $object->initiate_multipart_upload,
"can initiate a new multipart upload -- $upload_id"
);
#put part
my $put_part_response;
ok(
$put_part_response = $object->put_part(
part_number => 1,
upload_id => $upload_id,
value => 'x' x ( 5 * 1024 * 1024 )
),
'Got a successful response for PUT part'
);
ok( $put_part_response->header('ETag'), 'etag ok' );
ok(
my $abort_response =
$object->abort_multipart_upload( upload_id => $upload_id ),
'Got a successful response for DELETE multipart upload'
);
ok( !$object->exists, "object has now been deleted" );
}
# upload an object using multipart upload
$object = $bucket->object(
key => 'new multipart file',
acl_short => 'public-read'
);
my $upload_id;
ok($upload_id = $object->initiate_multipart_upload, "can initiate a new multipart upload");
#put part
my $put_part_response;
ok( $put_part_response = $object->put_part(part_number => 1, upload_id => $upload_id, value => 'x' x (5 * 1024 * 1024)), 'Got a successful response for PUT part' );
my @etags;
push @etags, $put_part_response->header('ETag');
ok( $put_part_response = $object->put_part(part_number => 2, upload_id => $upload_id, value => 'z' x (1024 * 1024)), 'Got a successful response for 2nd PUT part' );
push @etags, $put_part_response->header('ETag');
# TODO list part? - We've got this, but how to expose it nicely?
#complete multipart upload
my $complete_upload_response;
ok(
$complete_upload_response = $object->complete_multipart_upload( upload_id => $upload_id, part_numbers => [1,2], etags => \@etags),
"successful response for complete multipart upload"
);
#get the file and check that it looks like we expect
ok($object->exists, "object has now been created");
$tmp_fh = File::Temp->new();
$object->get_filename($tmp_fh->filename);
is( stat($tmp_fh->filename)->size, 6 * 1024 * 1024, "downloaded file has a size equivalent to the sum of it's parts");
$tmp_fh->seek((5 * 1024 * 1024) - 1, SEEK_SET);#jump to 5MB position
my $test_bytes;