Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Net-Amazon-S3 CPAN distribution.

Report information
The Basics
Id: 24683
Status: resolved
Priority: 0/
Queue: Net-Amazon-S3

People
Owner: Nobody in particular
Requestors: andy [...] hybridized.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Patch to add CommonPrefixes support
Hi guys, Here's a quick patch to add CommonPrefixes support. I also updated the docs a bit to reflect my changes. -Andy
Subject: common_prefixes.patch
diff -ur Net-Amazon-S3-0.37/lib/Net/Amazon/S3.pm Net-Amazon-S3-0.37-new/lib/Net/Amazon/S3.pm --- Net-Amazon-S3-0.37/lib/Net/Amazon/S3.pm 2006-10-13 14:20:47.000000000 -0400 +++ Net-Amazon-S3-0.37-new/lib/Net/Amazon/S3.pm 2007-01-30 21:46:56.000000000 -0500 @@ -384,11 +384,6 @@ the CommonPrefixes collection nor the NextMarker element will be present in the response. -NOTE (TODO): CommonPrefixes isn't currently supported by Net::Amazon::S3. -Patches welcome - - - =item max-keys This optional argument limits the number of results returned in @@ -424,19 +419,25 @@ The hashref looks like this: { - bucket => $bucket_name, - prefix => $bucket_prefix, - marker => $bucket_marker, - next_marker => $bucket_next_available_marker, - max_keys => $bucket_max_keys, - is_truncated => $bucket_is_truncated_boolean - keys => [$key1,$key2,...] + bucket => $bucket_name, + prefix => $bucket_prefix, + common_prefixes => [$prefix1,$prefix2,...] + marker => $bucket_marker, + next_marker => $bucket_next_available_marker, + max_keys => $bucket_max_keys, + is_truncated => $bucket_is_truncated_boolean + keys => [$key1,$key2,...] } Explanation of bits of that: =over +=item common_prefixes + +If list_bucket was requested with a delimiter, common_prefixes will +contain a list of prefixes matching that delimiter. Drill down into +these prefixes by making another request with the prefix parameter. =item is_truncated @@ -523,6 +524,22 @@ }; } $return->{keys} = \@keys; + + if ( $conf->{delimiter} ) { + my @common_prefixes; + my $strip_delim = qr/$conf->{delimiter}$/; + + foreach my $node ( $xpc->findnodes(".//s3:CommonPrefixes") ) { + my $prefix = $xpc->findvalue( ".//s3:Prefix", $node ); + + # strip delimiter from end of prefix + $prefix =~ s/$strip_delim//; + + push @common_prefixes, $prefix; + } + $return->{common_prefixes} = \@common_prefixes; + } + return $return; }
Thanks, applied (and in the new release 0.40)