| 3108 | } |
| 3109 | |
| 3110 | Result<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 | |
| 3142 | S3Options S3FileSystem::options() const { return impl_->options(); } |
| 3143 | |