Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traversing prefixed container to get all objects, but getObjectCount() returns number of all objects in the container without prefix #30

Open
leledumbo opened this issue Oct 16, 2015 · 0 comments

Comments

@leledumbo
Copy link

The following code is expected to return all objects under the given prefix as $container->objects

$client = new ObjectStorage($host, $username, $password);
$objectToRequest = 10000;
$container = $client->with('container')->setParam('prefix','a prefix')->get($objectToRequest);
while (count($container->objects) < $container->getObjectCount()) {
    $obj = end($container->objects);
    reset($container->objects);
    $marker = $obj->getPath();
    $container->get($objectToRequest, $marker);
}

However, the code runs indefinitely. And when I add:

echo count($container->objects).' = '.$container->getObjectCount();

in the loop, I see that the values are static where $container->getObjectCount() shows the number of all objects in the unprefixed container, while count($container->objects) shows the number of all objects in the prefixed container.

The reason for the loop is because get() maximum returns 10000 objects per call, so for prefixes which have more than 10000 objects the call must be repeated with marker as last retrieved object.

My question is:

  1. Is my understanding about the methods correct?
  2. Is the above code correct? i.e. doing what I intend to do as explained above? If not, what's the correct one?

Regards,

Mario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant