You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "chitralverma (via GitHub)" <gi...@apache.org> on 2023/09/15 13:58:32 UTC
[GitHub] [incubator-opendal] chitralverma edited a comment on the discussion: [Feature Request] Support creating operator from resource URI
GitHub user chitralverma edited a comment on the discussion: [Feature Request] Support creating operator from resource URI
@Xuanwo @frostming , currently I'm using something like this over a typical `Url` as a naive hack. I believe something more sophisticated can be added on similar lines?
FYI, link to something similar that `object_store` does - [link](https://github.com/apache/arrow-rs/blob/7355e8392d6e82c28cc54236d79b4dc56d7226d4/object_store/src/parse.rs#L71C9-L71C9)
```
pub fn infer_operator(&self, opts: HashMap<String, String>) -> Result<Operator, Error> {
let mut _opts = opts;
let scheme = match (self.url.scheme(), self.url.host_str()) {
("file", None) => Scheme::Fs,
("az", _) => Scheme::Azblob,
("adl" | "adls" | "abfs" | "abfss" | "azdfs" | "azdls", _) => Scheme::Azdfs,
("s3" | "s3a", Some(bucket)) => {
_opts.insert("bucket".to_string(), bucket.to_string());
Scheme::S3
}
("gs", Some(bucket)) => {
_opts.insert("bucket".to_string(), bucket.to_string());
Scheme::Gcs
}
(scheme, _) => {
return Err(OpenDalError::new(
OpenDalErrorKind::Unsupported,
format!("Unable to recognise URL with scheme \"{scheme}\"",).as_str(),
)
.into());
}
};
```
GitHub link: https://github.com/apache/incubator-opendal/discussions/1494#discussioncomment-7014631
----
This is an automatically sent email for commits@opendal.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@opendal.apache.org