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

Method MakeUri

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

Source from the content-addressed store, hash-verified

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

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