POE-Component-Amazon-S3
view release on metacpan or search on metacpan
lib/POE/Component/Amazon/S3.pm view on Meta::CPAN
my %params = @_;
croak "$class requires aws_access_key_id and aws_secret_access_key"
unless $params{aws_access_key_id} && $params{aws_secret_access_key};
$params{libxml} = XML::LibXML->new;
my $self = bless \%params, $class;
# A non-streaming HTTP client for most requests
POE::Component::Client::HTTP->spawn(
Agent => 'POE-Component-Amazon-S3/' . $VERSION,
Alias => 'ua',
Timeout => 30,
);
# A streaming HTTP client for downloads
POE::Component::Client::HTTP->spawn(
Agent => 'POE-Component-Amazon-S3/' . $VERSION,
Alias => 'ua-streaming',
Timeout => 30,
Streaming => $BLOCK_SIZE,
);
POE::Session->create(
object_states => [
$self => [
qw/
_start
shutdown
lib/POE/Component/Amazon/S3.pm view on Meta::CPAN
my ( $kernel, $self ) = @_[ KERNEL, OBJECT ];
$kernel->alias_set( $self->{alias} || 's3' );
}
sub shutdown {
my ( $kernel, $self ) = @_[ KERNEL, OBJECT ];
# Shut down our HTTP clients
$kernel->post( ua => 'shutdown' );
$kernel->post( 'ua-streaming' => 'shutdown' );
$kernel->alias_remove( $self->{alias} || 'amazon-s3' );
}
### Bucket methods
sub add_bucket {
my ( $kernel, $self, $sender, $event, $conf ) = @_[ KERNEL, OBJECT, SENDER, ARG0, ARG1 ];
my $bucket = $conf->{bucket};
lib/POE/Component/Amazon/S3.pm view on Meta::CPAN
my $request = $self->_make_request( GET => $self->_uri( $bucket, $key ) );
# Save callback info
my $pass = {
sender => $sender,
event => $event,
file => $file,
pass => $conf->{pass} || [],
};
$kernel->post( 'ua-streaming' => request => get_key_done => $request, $pass );
}
sub get_key_done {
my ( $kernel, $self, $req, $res ) = @_[ KERNEL, OBJECT, ARG0, ARG1 ];
my $request = $req->[0];
my $pass = $req->[1];
my $response = $res->[0];
my $chunk = $res->[1];
( run in 0.240 second using v1.01-cache-2.11-cpan-4d50c553e7e )