Removed /usr/local from CDPATH
[clearscm.git] / aws / test.pl
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use Paws;
6
7 my $bucket         = 'defaria-aws.com';
8
9 sub get_remote_objects ($) {
10   my ($s3) = @_;
11
12   my (%remote_objects, $token, $truncated);
13
14   do {
15     my $response = $s3->ListObjectsV2(
16       Bucket => $bucket,
17       ($token ? (ContinuationToken => $token) : ()),
18     );
19
20     for (@{$response->{Contents}}) {
21       $remote_objects{$_->{Key}} = Time::Piece->strptime($_->{LastModified}, '%Y-%m-%dT%T.000Z')->epoch;
22     } # for
23
24     if ($response->{isTruncated}) {
25       $token = $response->{NextContinuationToken};
26       $truncated = 1;
27     }  # if
28   } while ($truncated);
29
30   return \%remote_objects;
31 } # get_remote_objects
32
33 # Let's get the files in the S3 bucket
34 my $s3             = Paws->service('S3', region => 'us-west-1');
35 my $remote_objects = get_remote_objects($s3);
36
37 for (keys %$remote_objects) {
38   print "$_\n";
39 } # for
40
41 print "done\n";