How do I get a list of all objects in a bucket of Amazon S3? I'm using Zend Framework which has Amazon S3 library built-in. But it doesn't have method to retrieve all objects instead of 1000 limit objects.
Here's how I do it:
require_once 'Zend/Service/Amazon/S3.php';
$s3 = new Zend_Service_Amazon_S3(S3_ACCESS_KEY, S3_SECRET_KEY);
$s3->setEndpoint(S3_END_POINT);
$objects = $s3->getObjectsByBucket($bucket, array('prefix' => 'albums/', 'delimiter' => '/'));
// object returns 1000 objects as per API limitation
foreach ($objects as $object) {
//
}
I've found some workaround on this, which provided by Zend docs itself. It uses getIterator() method to list ALL objects in a bucket. BUT, this method doesn't exist in Zend S3 Library I'm using now, unless I update it, which might cause some problem to existing system I'm developing.
I've searched for the source code of getIterator but couldn't find it.
Is there any other way around this?
Aucun commentaire:
Enregistrer un commentaire