When listing objects in a bucket it seems the same paging functionality can be accomplished using either ContinuationToken or StartAfter. Consider the following boto3 code:
ContinuationToken:
objects = s3cli.list_objects_v2(Bucket='some-bucket', MaxKeys=20)
do_something(objects)
while (objects['IsTruncated']):
objects = s3cli.list_objects_v2(Bucket='some-bucket', MaxKeys=20, ContinuationToken=objects['NextContinuationToken'])
do_something(objects)
StartAfter:
objects = s3cli.list_objects_v2(Bucket='some-bucket', MaxKeys=20)
do_something(objects)
while (objects['IsTruncated']):
objects = s3cli.list_objects_v2(Bucket=bucket, MaxKeys=20, StartAfter=objects['Contents'][-1]['Key'])
do_something(objects)
Both of these loop through 20 objects at a time and take some action on them. Are there specific benefits or pitfalls (efficiency, cost, etc) to using one over the other? Is there something ContinuationToken can do (or is better at) that StartAfter cannot?
This question is closely related.