diff --git a/core/Cargo.toml b/core/Cargo.toml index c436be1f1303..4477c84bb30d 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -275,7 +275,7 @@ sqlx = { version = "0.8.0", features = [ ], optional = true } # For http based services. -reqsign = { version = "0.16", default-features = false, optional = true } +reqsign = { version = "0.16.1", default-features = false, optional = true } # for services-atomic-server atomic_lib = { version = "0.39.0", optional = true } diff --git a/core/src/services/s3/backend.rs b/core/src/services/s3/backend.rs index 43f266e7c6a4..4c9d6b5973f3 100644 --- a/core/src/services/s3/backend.rs +++ b/core/src/services/s3/backend.rs @@ -668,7 +668,7 @@ impl Builder for S3Builder { const SCHEME: Scheme = Scheme::S3; type Config = S3Config; - fn build(self) -> Result { + fn build(mut self) -> Result { debug!("backend build started: {:?}", &self); let root = normalize_root(&self.config.root.clone().unwrap_or_default()); @@ -753,9 +753,10 @@ impl Builder for S3Builder { } } - if let Some(v) = self.config.region.clone() { - cfg.region = Some(v); + if let Some(ref v) = self.config.region { + cfg.region = Some(v.to_string()); } + if cfg.region.is_none() { return Err(Error::new( ErrorKind::ConfigInvalid, @@ -768,6 +769,9 @@ impl Builder for S3Builder { let region = cfg.region.to_owned().unwrap(); debug!("backend use region: {region}"); + // Retain the user's endpoint if it exists; otherwise, try loading it from the environment. + self.config.endpoint = self.config.endpoint.or_else(|| cfg.endpoint_url.clone()); + // Building endpoint. let endpoint = self.build_endpoint(®ion); debug!("backend use endpoint: {endpoint}"); diff --git a/core/src/services/s3/config.rs b/core/src/services/s3/config.rs index 291706f5c16b..b1b31d5bbc72 100644 --- a/core/src/services/s3/config.rs +++ b/core/src/services/s3/config.rs @@ -51,7 +51,9 @@ pub struct S3Config { /// If user inputs endpoint without scheme like "s3.amazonaws.com", we /// will prepend "https://" before it. /// - /// default to `https://s3.amazonaws.com` if not set. + /// - If endpoint is set, we will take user's input first. + /// - If not, we will try to load it from environment. + /// - If still not set, default to `https://s3.amazonaws.com`. pub endpoint: Option, /// Region represent the signing region of this endpoint. This is required /// if you are using the default AWS S3 endpoint.