mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-16 04:58:00 +00:00
better loop
This commit is contained in:
@@ -42,13 +42,30 @@ class S3Storage implements StorageController
|
|||||||
{
|
{
|
||||||
if(!$this->s3)$this->connect();
|
if(!$this->s3)$this->connect();
|
||||||
|
|
||||||
$iterator = $this->s3->getIterator('ListObjects', [
|
$KeyCount = 9999;
|
||||||
'Bucket' => S3_BUCKET
|
$keys = 10;
|
||||||
]);
|
$lastkey = false;
|
||||||
|
$count = 0;
|
||||||
$items = array();
|
$items = array();
|
||||||
foreach ($iterator as $object) {
|
while($KeyCount>=$keys)
|
||||||
$items[] = $object['Key'];
|
{
|
||||||
|
$objects = $this->s3->listObjectsV2([
|
||||||
|
'Bucket' => S3_BUCKET,
|
||||||
|
'MaxKeys'=> $keys,
|
||||||
|
'StartAfter'=>($lastkey?$lastkey:'')
|
||||||
|
]);
|
||||||
|
|
||||||
|
++$count;
|
||||||
|
foreach ($objects['Contents'] as $object){
|
||||||
|
//echo $count." {$object['Key']}\n";
|
||||||
|
$lastkey = $object['Key'];
|
||||||
|
$items[] = $lastkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($dev===true)
|
||||||
|
echo "Got ".($count*$keys)." files \r";
|
||||||
|
|
||||||
|
$KeyCount = $objects['KeyCount'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
|
|||||||
Reference in New Issue
Block a user