From c09ad2b855c09c7e7df78d7565e47b0887b1de10 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Thu, 16 Jan 2025 16:16:25 -0300 Subject: [PATCH] feat(ssstar): add force_path_style config Introduces a new force_path_style configuration that maps to https://docs.rs/aws-sdk-s3/latest/aws_sdk_s3/config/struct.Builder.html#method.force_path_style --- ssstar/src/config.rs | 5 +++++ ssstar/src/objstore/s3.rs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ssstar/src/config.rs b/ssstar/src/config.rs index da2d402..ca97c27 100644 --- a/ssstar/src/config.rs +++ b/ssstar/src/config.rs @@ -131,6 +131,10 @@ pub struct Config { /// This defaults to something provided by the AWS SDK for Rust. #[cfg_attr(feature = "clap", clap(long, global = true))] pub user_agent: Option, + + /// Force the client to use path-style addressing for buckets. + #[cfg_attr(feature = "clap", clap(long, global = true))] + pub force_path_style: bool, } impl Default for Config { @@ -153,6 +157,7 @@ impl Default for Config { max_concurrent_requests: 10, max_queue_size: 1000, user_agent: None, + force_path_style: false, } } } diff --git a/ssstar/src/objstore/s3.rs b/ssstar/src/objstore/s3.rs index 8eb26c6..a017b50 100644 --- a/ssstar/src/objstore/s3.rs +++ b/ssstar/src/objstore/s3.rs @@ -1526,6 +1526,10 @@ async fn make_s3_client( .map_err(|err| crate::S3TarError::HeaderValueConvertion { source: err })?, }); + if config.force_path_style { + s3_config_builder = s3_config_builder.force_path_style(true); + } + if let Some(s3_endpoint) = &config.s3_endpoint { s3_config_builder = s3_config_builder.endpoint_url(s3_endpoint.to_string()); }