Skip to content

Commit a51f5c8

Browse files
committed
Simplify example for listing more than 10,000 files
1 parent 8c5cb50 commit a51f5c8

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

samples/ObjectStore/list-objects-over-10000.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,20 @@
3737

3838
// 5. Create a list of all objects in the container
3939
$containerObjects = array();
40-
$marker = '';
40+
$latestFilename = '';
41+
$batchCount = null;
4142

42-
while ($marker !== null) {
43+
while ($batchCount !== 0) {
4344
$params = array(
44-
'marker' => $marker,
45+
'marker' => $latestFilename,
4546
);
4647

4748
$objects = $container->objectList($params);
48-
$total = $objects->count();
49-
$count = 0;
50-
51-
if ($total == 0) {
52-
break;
53-
}
49+
$batchCount = $objects->count();
5450

5551
foreach ($objects as $object) {
56-
/** @var $object OpenCloud\ObjectStore\Resource\DataObject **/
57-
$containerObjects[] = $object->getName();
58-
$count++;
59-
60-
$marker = ($count == $total) ? $object->getName() : null;
52+
/** @var $object \OpenCloud\ObjectStore\Resource\DataObject **/
53+
$latestFilename = $object->getName();
54+
$containerObjects[] = $latestFilename;
6155
}
6256
}

0 commit comments

Comments
 (0)