From 15e3ec635a913e418edffc8343cd4af7fcec1850 Mon Sep 17 00:00:00 2001 From: Willem Kaufmann Date: Wed, 1 May 2024 10:27:54 -0400 Subject: [PATCH] cloud_storage: fix s3 request parameters In `ListObjectsV2` for the `s3_client`, `prefix`, `delimiter`, `start_after`, and `continuation-token` are all URI parameters, not request headers. --- src/v/cloud_storage_clients/s3_client.cc | 27 +++++++----------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/v/cloud_storage_clients/s3_client.cc b/src/v/cloud_storage_clients/s3_client.cc index 8356dbd619a08..420bf532046a1 100644 --- a/src/v/cloud_storage_clients/s3_client.cc +++ b/src/v/cloud_storage_clients/s3_client.cc @@ -203,12 +203,18 @@ request_creator::make_list_objects_v2_request( if (prefix.has_value()) { key = fmt::format("{}&prefix={}", key, (*prefix)().string()); } - if (delimiter.has_value()) { - key = fmt::format("{}&delimiter={}", key, *delimiter); + if (start_after.has_value()) { + key = fmt::format("{}&start-after={}", key, *start_after); } if (max_keys.has_value()) { key = fmt::format("{}&max-keys={}", key, *max_keys); } + if (continuation_token.has_value()) { + key = fmt::format("{}&continuation-token={}", key, *continuation_token); + } + if (delimiter.has_value()) { + key = fmt::format("{}&delimiter={}", key, *delimiter); + } auto target = make_target(name, object_key{key}); header.method(boost::beast::http::verb::get); header.target(target); @@ -217,23 +223,6 @@ request_creator::make_list_objects_v2_request( header.insert(boost::beast::http::field::host, host); header.insert(boost::beast::http::field::content_length, "0"); - if (prefix) { - header.insert(aws_header_names::prefix, (*prefix)().string()); - } - if (start_after) { - header.insert(aws_header_names::start_after, (*start_after)().string()); - } - if (continuation_token) { - header.insert( - aws_header_names::continuation_token, - {continuation_token->data(), continuation_token->size()}); - } - - if (delimiter) { - header.insert( - aws_header_names::delimiter, std::string(1, delimiter.value())); - } - auto ec = _apply_credentials->add_auth(header); vlog(s3_log.trace, "ListObjectsV2:\n {}", header); if (ec) {