X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=aws%2Ftest.pl;fp=aws%2Ftest.pl;h=b8b4bdd5b71b22cdf2c07d3a1af95490f3b44ba5;hb=7bd72db0aa6418669f29f8015b5e0ebdc21f1a6d;hp=0000000000000000000000000000000000000000;hpb=49b3d4933c2fcfd5a2665a4ffb9cb7ccd0184c10;p=clearscm.git diff --git a/aws/test.pl b/aws/test.pl new file mode 100755 index 0000000..b8b4bdd --- /dev/null +++ b/aws/test.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Paws; + +my $bucket = 'defaria-aws.com'; + +sub get_remote_objects ($) { + my ($s3) = @_; + + my (%remote_objects, $token, $truncated); + + do { + my $response = $s3->ListObjectsV2( + Bucket => $bucket, + ($token ? (ContinuationToken => $token) : ()), + ); + + for (@{$response->{Contents}}) { + $remote_objects{$_->{Key}} = Time::Piece->strptime($_->{LastModified}, '%Y-%m-%dT%T.000Z')->epoch; + } # for + + if ($response->{isTruncated}) { + $token = $response->{NextContinuationToken}; + $truncated = 1; + } # if + } while ($truncated); + + return \%remote_objects; +} # get_remote_objects + +# Let's get the files in the S3 bucket +my $s3 = Paws->service('S3', region => 'us-west-1'); +my $remote_objects = get_remote_objects($s3); + +for (keys %$remote_objects) { + print "$_\n"; +} # for + +print "done\n";