Amazon-S3-Lite

 view release on metacpan or  search on metacpan

lib/Amazon/S3/Lite.pm  view on Meta::CPAN


  # Create a bucket
  $s3->create_bucket('my-bucket');
  $s3->create_bucket('my-bucket', region => 'eu-west-1');

  # Configure a Lambda notification trigger
  $s3->put_bucket_notification_configuration('my-bucket',
    type       => 'lambda',
    lambda_arn => $function_arn,
    events     => 's3:ObjectCreated:*',
    filters    => { prefix => 'uploads/' },
  );

  # Configure an SQS notification trigger
  $s3->put_bucket_notification_configuration('my-bucket',
    type      => 'sqs',
    queue_arn => $queue_arn,
    events    => 's3:ObjectCreated:*',
  );

  # Retrieve notification configuration

lib/Amazon/S3/Lite.pm  view on Meta::CPAN

lightweight scripts: listing buckets, listing objects, reading,
writing, copying, and deleting.

It is built on L<HTTP::Tiny> (core since Perl 5.14) and
L<Amazon::Signature4::Lite>, with no dependency on LWP or any part of
the libwww-perl ecosystem. The dependency list is intentionally small,
making it well-suited for Lambda container images where minimizing
cold-start time and image size matters.

It is not a replacement for L<Amazon::S3> or L<Net::Amazon::S3>, which
support the full S3 API surface including multipart upload, bucket
management, ACLs, versioning, and presigned URLs. If you need those
features, use one of those distributions instead.

L<Amazon::S3::Thin> is another excellent lightweight S3 client with a
similar philosophy and a longer track record. It is more complete than
this module - supporting presigned URLs, bulk delete, and
virtual-hosted-style requests - and returns raw L<HTTP::Response>
objects so callers handle status codes and errors
themselves. C<Amazon::S3::Lite> differs in three ways: it has no
dependency on LWP (C<Amazon::S3::Thin> defaults to L<LWP::UserAgent>),

lib/Amazon/S3/Lite.pm  view on Meta::CPAN

    type       => 'lambda',
    lambda_arn => $function_arn,
    events     => 's3:ObjectCreated:*',
  );

  # SQS trigger
  $s3->put_bucket_notification_configuration($bucket,
    type      => 'sqs',
    queue_arn => $queue_arn,
    events    => [qw(s3:ObjectCreated:* s3:ObjectRemoved:*)],
    filters   => { prefix => 'uploads/', suffix => '.csv' },
  );

Sets the bucket notification configuration for C<$bucket>, routing
S3 events to a Lambda function or SQS queue.

Options:

=over 4

=item type (required)

share/README.md  view on Meta::CPAN


    # Create a bucket
    $s3->create_bucket('my-bucket');
    $s3->create_bucket('my-bucket', region => 'eu-west-1');

    # Configure a Lambda notification trigger
    $s3->put_bucket_notification_configuration('my-bucket',
      type       => 'lambda',
      lambda_arn => $function_arn,
      events     => 's3:ObjectCreated:*',
      filters    => { prefix => 'uploads/' },
    );

    # Configure an SQS notification trigger
    $s3->put_bucket_notification_configuration('my-bucket',
      type      => 'sqs',
      queue_arn => $queue_arn,
      events    => 's3:ObjectCreated:*',
    );

    # Retrieve notification configuration

share/README.md  view on Meta::CPAN

lightweight scripts: listing buckets, listing objects, reading,
writing, copying, and deleting.

It is built on [HTTP::Tiny](https://metacpan.org/pod/HTTP%3A%3ATiny) (core since Perl 5.14) and
[Amazon::Signature4::Lite](https://metacpan.org/pod/Amazon%3A%3ASignature4%3A%3ALite), with no dependency on LWP or any part of
the libwww-perl ecosystem. The dependency list is intentionally small,
making it well-suited for Lambda container images where minimizing
cold-start time and image size matters.

It is not a replacement for [Amazon::S3](https://metacpan.org/pod/Amazon%3A%3AS3) or [Net::Amazon::S3](https://metacpan.org/pod/Net%3A%3AAmazon%3A%3AS3), which
support the full S3 API surface including multipart upload, bucket
management, ACLs, versioning, and presigned URLs. If you need those
features, use one of those distributions instead.

[Amazon::S3::Thin](https://metacpan.org/pod/Amazon%3A%3AS3%3A%3AThin) is another excellent lightweight S3 client with a
similar philosophy and a longer track record. It is more complete than
this module - supporting presigned URLs, bulk delete, and
virtual-hosted-style requests - and returns raw [HTTP::Response](https://metacpan.org/pod/HTTP%3A%3AResponse)
objects so callers handle status codes and errors
themselves. `Amazon::S3::Lite` differs in three ways: it has no
dependency on LWP (`Amazon::S3::Thin` defaults to [LWP::UserAgent](https://metacpan.org/pod/LWP%3A%3AUserAgent)),

share/README.md  view on Meta::CPAN

      type       => 'lambda',
      lambda_arn => $function_arn,
      events     => 's3:ObjectCreated:*',
    );

    # SQS trigger
    $s3->put_bucket_notification_configuration($bucket,
      type      => 'sqs',
      queue_arn => $queue_arn,
      events    => [qw(s3:ObjectCreated:* s3:ObjectRemoved:*)],
      filters   => { prefix => 'uploads/', suffix => '.csv' },
    );

Sets the bucket notification configuration for `$bucket`, routing
S3 events to a Lambda function or SQS queue.

Options:

- type (required)

    The notification target type. Must be `lambda` or `sqs`.

t/02-put-bucket-website.t  view on Meta::CPAN

          aws_access_key_id     => $ENV{AWS_ACCESS_KEY_ID},
          aws_secret_access_key => $ENV{AWS_SECRET_ACCESS_KEY},
          $ENV{SESSION_TOKEN} ? ( token => $ENV{SESSION_TOKEN} ) : (),
        ),
      }
    );
  };
}

########################################################################
sub upload_index {
########################################################################
  my ( $s3, $bucket ) = @_;

  my $index = <<'END_OF_INDEX';
<html>
Hello World!
</html>
END_OF_INDEX

  $s3->put_object( $bucket, 'index.html', $index, 'Content-type' => 'text/html' );

t/02-put-bucket-website.t  view on Meta::CPAN

########################################################################

  ok( eval { $s3->create_bucket($bucket); } ) or do {
    BAIL_OUT("Could not create bucket $bucket: $EVAL_ERROR");
  };

  ok( eval { $s3->put_bucket_website($bucket); } ) or do {
    BAIL_OUT("Could not create bucket website: $EVAL_ERROR");
  };

  upload_index( $s3, $bucket );

  my $response = eval { HTTP::Tiny->new->get( sprintf 'http://%s/index.html', $bucket ); };
  ok( $response && $response->{success} && $response->{content} =~ /hello\sworld/sxmi )
    or do {
    diag( Dumper( [ response => $response ] ) );
    };

  $s3->delete_object( $bucket, 'index.html' );

  $s3->delete_bucket($bucket);



( run in 1.047 second using v1.01-cache-2.11-cpan-b16cb0d3907 )