MCPcopy Create free account
hub / github.com/apache/arrow / MakeUri

Method MakeUri

cpp/src/arrow/filesystem/s3fs.cc:3110–3140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3108}
3109
3110Result<std::string> S3FileSystem::MakeUri(std::string path) const {
3111 if (path.length() <= 1 || path[0] != '/') {
3112 return Status::Invalid("MakeUri requires an absolute, non-root path, got ", path);
3113 }
3114 ARROW_ASSIGN_OR_RAISE(auto uri_from_path, util::UriFromAbsolutePath(path));
3115 constexpr std::string_view kFileScheme = "file://";
3116 std::string_view uri_view(uri_from_path);
3117 if (uri_view.starts_with(kFileScheme)) {
3118 uri_view.remove_prefix(kFileScheme.size());
3119 }
3120 if (uri_view.starts_with("/")) {
3121 // Remove leading slash if present
3122 uri_view.remove_prefix(1);
3123 }
3124 std::string uri = "s3://";
3125 if (!options().GetAccessKey().empty()) {
3126 uri += options().GetAccessKey() + ":" + options().GetSecretKey() + "@";
3127 }
3128 uri += std::string(uri_view);
3129 uri += "?";
3130 uri += "region=" + util::UriEscape(options().region);
3131 uri += "&";
3132 uri += "scheme=" + util::UriEscape(options().scheme);
3133 uri += "&";
3134 uri += "endpoint_override=" + util::UriEscape(options().endpoint_override);
3135 uri += "&";
3136 uri += "allow_bucket_creation="s + (options().allow_bucket_creation ? "1" : "0");
3137 uri += "&";
3138 uri += "allow_bucket_deletion="s + (options().allow_bucket_deletion ? "1" : "0");
3139 return uri;
3140}
3141
3142S3Options S3FileSystem::options() const { return impl_->options(); }
3143

Callers 2

TEST_FFunction · 0.45
TEST_FFunction · 0.45

Calls 8

optionsFunction · 0.85
UriEscapeFunction · 0.85
GetAccessKeyMethod · 0.80
GetSecretKeyMethod · 0.80
InvalidFunction · 0.50
lengthMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by 2

TEST_FFunction · 0.36
TEST_FFunction · 0.36