Net::Amazon::S3::ACL is a Perl module that represents an S3 Access Control List; it is a representation of the XML ACL that is easier to handle. As such, there are methods that ease passing from one representation to the other, namely "parse" (to parse an XML document into an object) and "stringify" (to get the XML representation of the ACL).
SYNOPSIS
use Net::Amazon::S3::ACL;
# analysis. Say you have a Net::Amazon::S3::Bucket...
my $xml_acl = $bucket->get_acl();
my $acl = Net::Amazon::S3::ACL->new({xml => $xml_acl});
# Now you can use it
print $acl->dump();
my $owner_id = $acl->owner_id();
my $owner_display_name = $acl->owner_displayname();
while (my ($name, $grant) = each %{$acl->grants()}) {
print "Policy for '$name':\n";
(my $type = ref $grant) =~ s/.*:://;
print " Type: $grant->{type}\n";
if ($type eq 'ID') {
print " AWS ID: ", $grant->id(), "\n";
print " AWS Display Name: ", $grant->displayname(), "\n";
}
elsif ($type eq 'Email') {
print " email address: ", $grant->email(), "\n";
}
elsif ($type eq 'URI') {
print " group definition URI: ", $grant->URI(), "\n";
}
print ' Permissions: ', join(', ', @{$grant->{permissions}}), "\n";
}
$acl->clear(); # wipe all grants in ACL object
# Straightforward addition of permissions, DWIM
$acl->add(
'foo@example.com' => 'READ', # seems email, added as such
'http://whatever/' => 'WRITE', # seems URI, added as such
'dafadfda908940394...' => '*', # added as AWS identifier
);
# Detailed addition of permissions, e.g. by ID
my $grant = Net::Amazon::S3::Grant::ID->new(
{
ID => 'long-AWS-ID-here',
displayname => 'display-name-here',
permissions => [qw( WRITE READ READ_ACP )],
}
);
$acl->add($grant);
my $ID = 'some-AWS-ID';
$acl->delete($ID); # remove whole ACL for given ID
$acl->delete($ID => 'READ'); # remove this permission only
$acl->delete($ID => [qw( READ WRITE )]); # remove these permissions only
# install new ACL
$bucket->set_acl({acl_xml => $acl->stringify()});
$bucket->set_acl({acl_xml => $acl->stringify(), key => 'whatever'});
Product's homepage
Requirements:
· Perl