With AWS SDK for C++ ListObjectsRequest, is there a way to have the SDK return the newest objects in the bucket based on the value of Set Marker? In the below code, the problem is that the objects in the object_list vector are newest to oldest. So, setting "last_key" to the key of the "back()" element results in 0 results the next time through in the loop (because there is nothing older than "last_key.")
If I set "last_key" to the key value of "front()" you end up looping over the same bucket objects over again.
Is there a way to use "last_key" that tells the SDK to get objects NEWER than "last_key"?
Aws::String last_marker;
while(true) {
Aws::S3::Model::ListObjectsRequest objects_request;
objects_request.WithBucket(bucket);
if (last_key.length() > 0) {
objects_request.SetMarker(last_key);
}
Aws::S3::Model::ListObjectsOutcome outcome;
outcome = s_client.ListObjects(objects_request);
Aws::Vector<Aws::S3::Model::Object> object_list =
outcome.GetResult().GetContents();
//loop through object vector.
last_marker.assign(object_list.back().GetKey());
}