def _handle_list_objects_v2(self, bucket_name, querystring):
    template = self.response_template(S3_BUCKET_GET_RESPONSE_V2)
    bucket = self.backend.get_bucket(bucket_name)
    continuation_token = querystring.get('continuation-token', [None])[0]
    if ((continuation_token is not None) and (continuation_token == '')):
        raise InvalidContinuationToken()
    prefix = querystring.get('prefix', [None])[0]
    if (prefix and isinstance(prefix, bytes)):
        prefix = prefix.decode('utf-8')
    delimiter = querystring.get('delimiter', [None])[0]
    all_keys = self.backend.list_objects_v2(bucket, prefix, delimiter)
    fetch_owner = querystring.get('fetch-owner', [False])[0]
    max_keys = int(querystring.get('max-keys', [1000])[0])
    start_after = querystring.get('start-after', [None])[0]
    if (continuation_token or start_after):
        limit = (continuation_token or start_after)
        all_keys = self._get_results_from_token(all_keys, limit)
    (truncated_keys, is_truncated, next_continuation_token) = self._truncate_result(all_keys, max_keys)
    (result_keys, result_folders) = self._split_truncated_keys(truncated_keys)
    key_count = (len(result_keys) + len(result_folders))
    return template.render(bucket=bucket, prefix=(prefix or ''), delimiter=delimiter, key_count=key_count, result_keys=result_keys, result_folders=result_folders, fetch_owner=fetch_owner, max_keys=max_keys, is_truncated=is_truncated, next_continuation_token=next_continuation_token, start_after=(None if continuation_token else start_after))
def _handle_list_objects_v2(self, bucket_name, querystring):
    template = self.response_template(S3_BUCKET_GET_RESPONSE_V2)
    bucket = self.backend.get_bucket(bucket_name)
    continuation_token = querystring.get('continuation-token', [None])[0]
    if ((continuation_token is not None) and (continuation_token == )):
        raise InvalidContinuationToken()
    prefix = querystring.get('prefix', [None])[0]
    if (prefix and isinstance(prefix, bytes)):
        prefix = prefix.decode('utf-8')
    delimiter = querystring.get('delimiter', [None])[0]
    all_keys = self.backend.list_objects_v2(bucket, prefix, delimiter)
    fetch_owner = querystring.get('fetch-owner', [False])[0]
    max_keys = int(querystring.get('max-keys', [1000])[0])
    start_after = querystring.get('start-after', [None])[0]
    if (continuation_token or start_after):
        limit = (continuation_token or start_after)
        all_keys = self._get_results_from_token(all_keys, limit)
    (truncated_keys, is_truncated, next_continuation_token) = self._truncate_result(all_keys, max_keys)
    (result_keys, result_folders) = self._split_truncated_keys(truncated_keys)
    key_count = (len(result_keys) + len(result_folders))
    return template.render(bucket=bucket, prefix=(prefix or ), delimiter=delimiter, key_count=key_count, result_keys=result_keys, result_folders=result_folders, fetch_owner=fetch_owner, max_keys=max_keys, is_truncated=is_truncated, next_continuation_token=next_continuation_token, start_after=(None if continuation_token else start_after))