raulcd commented on code in PR #50205:
URL: https://github.com/apache/arrow/pull/50205#discussion_r3428118110
##########
cpp/src/arrow/filesystem/s3fs.cc:
##########
@@ -3052,13 +3052,21 @@ Result<std::string> S3FileSystem::MakeUri(std::string
path) const {
if (path.length() <= 1 || path[0] != '/') {
return Status::Invalid("MakeUri requires an absolute, non-root path, got
", path);
}
- ARROW_ASSIGN_OR_RAISE(auto uri, util::UriFromAbsolutePath(path));
+ ARROW_ASSIGN_OR_RAISE(auto uri_from_path, util::UriFromAbsolutePath(path));
+ constexpr std::string_view kFileScheme = "file://";
+ std::string_view uri_view(uri_from_path);
+ if (uri_view.starts_with(kFileScheme)) {
+ uri_view.remove_prefix(kFileScheme.size());
+ }
+ if (uri_view.starts_with("/")) {
+ // Remove leading slash if present
+ uri_view.remove_prefix(1);
+ }
+ std::string uri = "s3://";
if (!options().GetAccessKey().empty()) {
- uri = "s3://" + options().GetAccessKey() + ":" + options().GetSecretKey()
+ "@" +
- uri.substr("file:///"s.size());
- } else {
- uri = "s3" + uri.substr("file"s.size());
+ uri += options().GetAccessKey() + ":" + options().GetSecretKey() + "@";
}
Review Comment:
the copilot comments can potentially make sense but this is a different bug
unrelated to the one we are fixing. We could open an issue to fix it if it
makes sense. Not an expert on S3 URIs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]