Skip to content

Commit dbbbd89

Browse files
committed
Restore support for optional use_delimiter, sort req_params
1 parent 64a1095 commit dbbbd89

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/include/s3fs.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class S3FileSystem : public HTTPFileSystem {
289289
// Helper class to do s3 ListObjectV2 api call https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
290290
struct AWSListObjectV2 {
291291
static string Request(const string &path, HTTPParams &http_params, S3AuthParams &s3_auth_params,
292-
string &continuation_token, optional_idx max_keys = optional_idx());
292+
string &continuation_token, bool use_delimiter = false, optional_idx max_keys = optional_idx());
293293
static void ParseFileList(string &aws_response, vector<OpenFileInfo> &result);
294294
static vector<string> ParseCommonPrefix(string &aws_response);
295295
static string ParseContinuationToken(string &aws_response);

src/s3fs.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ HTTPException S3FileSystem::GetHTTPError(FileHandle &handle, const HTTPResponse
14091409
}
14101410

14111411
string AWSListObjectV2::Request(const string &path, HTTPParams &http_params, S3AuthParams &s3_auth_params,
1412-
string &continuation_token, optional_idx max_keys) {
1412+
string &continuation_token, bool use_delimiter, optional_idx max_keys) {
14131413
const idx_t MAX_RETRIES = 1;
14141414
for (idx_t it = 0; it <= MAX_RETRIES; it++) {
14151415
auto parsed_url = S3FileSystem::S3UrlParse(path, s3_auth_params);
@@ -1418,15 +1418,21 @@ string AWSListObjectV2::Request(const string &path, HTTPParams &http_params, S3A
14181418
string req_path = parsed_url.path.substr(0, parsed_url.path.length() - parsed_url.key.length());
14191419

14201420
string req_params;
1421+
// NOTE: req_params needs to be sorted
14211422
if (!continuation_token.empty()) {
14221423
req_params += "continuation-token=" + S3FileSystem::UrlEncode(continuation_token, true);
14231424
req_params += "&";
14241425
}
1426+
1427+
if (use_delimiter) {
1428+
req_params += "delimiter=%2F&";
1429+
}
1430+
14251431
req_params += "encoding-type=url&list-type=2";
1426-
req_params += "&prefix=" + S3FileSystem::UrlEncode(parsed_url.key, true);
14271432
if (max_keys.IsValid()) {
14281433
req_params += "&max-keys=" + to_string(max_keys.GetIndex());
14291434
}
1435+
req_params += "&prefix=" + S3FileSystem::UrlEncode(parsed_url.key, true);
14301436

14311437
auto header_map =
14321438
CreateS3Header(req_path, req_params, parsed_url.host, "s3", "GET", s3_auth_params, "", "", "", "");

0 commit comments

Comments
 (0)