I am listing all the available versions of a particular key on s3. Two issues:
Issue #2 isn't a big deal for me. But #1 is a show stopper.
Here is a code snippet:
Model::ListObjectVersionsRequest object_request;
object_request.WithBucket(this->bucket_name);
object_request.WithKeyMarker( ... + ".json");
do {
auto list_versions_outcome = this->s3_client->ListObjectVersions(object_request);
//...
//prepare for next iteration
object_request.SetVersionIdMarker(list_versions_outcome.GetResult().GetNextVersionIdMarker());
} while (keep_looking);
thoughts?
So I found a workaround for this issue. The idea is to limit the size of the first page of version id results to just one. After that is done, we can bring the size of the pages back to 1000. Even if the first result gets the wrong version id, this does not matter since retrieving the most recent version is the default behavior of s3.
The code becomes:
Model::ListObjectVersionsRequest object_request;
object_request.WithBucket(this->bucket_name);
object_request.WithKeyMarker( ... + ".json");
object_request.WithMaxKeys(1);//HAX because of the first 1000 issue
do {
auto list_versions_outcome = this->s3_client->ListObjectVersions(object_request);
//...
//prepare for next iteration
object_request.SetVersionIdMarker(list_versions_outcome.GetResult().GetNextVersionIdMarker());
object_request.SetMaxKeys(1000); // reset the page number to 1000
} while (keep_looking);