Amazon-S3-Lite
view release on metacpan or search on metacpan
[1.1.2]:
* release-notes/release-notes-1.1.2.md
* VERSION: bump
* lib/Amazon/S3/Lite.pm.in
(_request)
- remove use of postfix if
(put_bucket_notification_configuration)
- set query string variable with '=' for signing
(get_bucket_notification_configuration)
- likewise
- log parsed reponse at debug level
(_parse_notification_configuration)
- elements to capture are CloudFunctionConfiguration, CloudFunction, not Lambda*
Thu May 14 10:00:33 2026 Rob Lauer <rclauer@gmail.com>
[1.1.1]:
* release-notes/release-notes-1.1.1.md: new
* releaes-notes-*.md => release-notes/
* VERSION: bump
* cpanfile: likewise
lib/Amazon/S3/Lite.pm view on Meta::CPAN
# Logger setup
# Priority: caller-supplied object -> Log::Log4perl (if available) ->
# minimal STDERR logger
########################################################################
sub _init_logger {
########################################################################
my ( $self, $logger ) = @_;
if ($logger) {
# Validate it quacks like a logger
for my $method (qw(trace debug info warn error)) {
croak "logger object must implement '$method'"
if !$logger->can($method);
}
$self->{logger} = $logger;
return;
}
if ( eval { require Log::Log4perl; 1 } ) {
if ( !Log::Log4perl->initialized ) {
Log::Log4perl->easy_init($Log::Log4perl::WARN);
lib/Amazon/S3/Lite.pm view on Meta::CPAN
my $signed = $self->_signer($region)->sign(
method => $method,
url => $url,
headers => $headers,
payload => $content_is_coderef ? q{} : $content,
);
# HTTP::Tiny sets Host itself â remove to avoid duplicate header error
delete $signed->{host};
$self->logger->debug("$method $url");
my $options = { headers => $signed };
if ( length $content || $content_is_coderef ) {
$options->{content} = $content;
}
if ( $extra->{data_callback} ) {
$options->{data_callback} = $extra->{data_callback};
}
my $response = $self->ua->request( $method, $url, $options );
$self->logger->debug( sprintf 'Response: %s %s', $response->{status}, $response->{reason} );
return $response;
}
########################################################################
# head_object( $bucket, $key )
#
# Fetches metadata for an object without retrieving the body.
# Returns undef if the key does not exist (404).
# Returns a hashref with content_type, content_length, etag,
lib/Amazon/S3/Lite.pm view on Meta::CPAN
if !defined $bucket || !length $bucket;
my $url = $self->_endpoint($bucket) . q{?notification=};
my $response = $self->_request( 'GET', $url );
$self->_croak_on_error( $response, 'get_bucket_notification_configuration' );
my $rsp = $self->_parse_notification_configuration( $response->{content} );
$self->logger->debug(
Dumper(
[ response => $response,
parsed_response => $rsp
]
)
);
return $rsp;
}
lib/Amazon/S3/Lite.pm view on Meta::CPAN
Any object that satisfies this interface is accepted -
L<Amazon::Credentials>, L<Paws::Credential::*>, or your own. The
getters are called at request time, so objects that refresh expiring
credentials transparently are supported.
=item logger
An object providing the standard log methods:
$logger->trace(...)
$logger->debug(...)
$logger->info(...)
$logger->warn(...)
$logger->error(...)
If not supplied, the module looks for L<Log::Log4perl>. If available,
it calls C<Log::Log4perl::easy_init> with level WARN and logs to
STDERR. If Log::Log4perl is not installed, a minimal internal logger
is used that prints WARN and above to STDERR.
=item host
lib/Amazon/S3/Lite/Logger.pm view on Meta::CPAN
package Amazon::S3::Lite::Logger;
use strict;
use warnings;
our $VERSION = '1.1.5';
sub new { return bless {}, shift }
sub trace { } # silent
sub debug { } # silent
sub info {
my ( $self, $msg ) = @_;
print {*STDERR} "INFO - $msg\n";
}
sub warn { ## no critic (Subroutines::ProhibitBuiltinHomonyms)
my ( $self, $msg ) = @_;
print {*STDERR} "WARN - $msg\n";
}
share/README.md view on Meta::CPAN
Any object that satisfies this interface is accepted -
[Amazon::Credentials](https://metacpan.org/pod/Amazon%3A%3ACredentials), [Paws::Credential::\*](https://metacpan.org/pod/Paws%3A%3ACredential%3A%3A%2A), or your own. The
getters are called at request time, so objects that refresh expiring
credentials transparently are supported.
- logger
An object providing the standard log methods:
$logger->trace(...)
$logger->debug(...)
$logger->info(...)
$logger->warn(...)
$logger->error(...)
If not supplied, the module looks for [Log::Log4perl](https://metacpan.org/pod/Log%3A%3ALog4perl). If available,
it calls `Log::Log4perl::easy_init` with level WARN and logs to
STDERR. If Log::Log4perl is not installed, a minimal internal logger
is used that prints WARN and above to STDERR.
- host
t/01-s3-lite.t view on Meta::CPAN
eval { Amazon::S3::Lite->new( { region => 'us-east-1', credentials => BadCreds->new } ) };
like $@, qr/must implement aws_secret_access_key/, 'bad creds object croaks';
}
# custom logger
{
my $warned = 0;
my $logger = bless {}, 'MyLogger';
{
no strict 'refs';
for my $m (qw(trace debug info error)) {
*{"MyLogger::$m"} = sub { };
}
*{"MyLogger::warn"} = sub { $warned++ };
}
my $s3l = new_s3( logger => $logger );
isa_ok $s3l->logger, 'MyLogger', 'custom logger accepted';
}
};
subtest '_endpoint' => sub {
( run in 1.229 second using v1.01-cache-2.11-cpan-5511b514fd6 )