You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by tu...@apache.org on 2024/10/29 15:06:14 UTC
(arrow-rs) branch master updated: [object_store] fix S3 endpoint and trailing slash result in invalid requests (#6641)
This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new 2b373f850c [object_store] fix S3 endpoint and trailing slash result in invalid requests (#6641)
2b373f850c is described below
commit 2b373f850c5ac3d8ba6a1a0dfb98f5711f5318c8
Author: lambda <1w...@live.com>
AuthorDate: Tue Oct 29 23:06:08 2024 +0800
[object_store] fix S3 endpoint and trailing slash result in invalid requests (#6641)
Co-authored-by: Yiwei Wang <yi...@Yiweis-MacBook-Pro.local>
---
object_store/src/aws/builder.rs | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/object_store/src/aws/builder.rs b/object_store/src/aws/builder.rs
index c52c3f8dfb..eb79f5e6dc 100644
--- a/object_store/src/aws/builder.rs
+++ b/object_store/src/aws/builder.rs
@@ -961,7 +961,7 @@ impl AmazonS3Builder {
let virtual_hosted = self.virtual_hosted_style_request.get()?;
let bucket_endpoint = match (&self.endpoint, zonal_endpoint, virtual_hosted) {
(Some(endpoint), _, true) => endpoint.clone(),
- (Some(endpoint), _, false) => format!("{endpoint}/{bucket}"),
+ (Some(endpoint), _, false) => format!("{}/{}", endpoint.trim_end_matches("/"), bucket),
(None, Some(endpoint), _) => endpoint,
(None, None, true) => format!("https://{bucket}.s3.{region}.amazonaws.com"),
(None, None, false) => format!("https://s3.{region}.amazonaws.com/{bucket}"),
@@ -1316,6 +1316,29 @@ mod tests {
assert_eq!(builder.client.config.region, "us-east-1");
}
+ #[test]
+ fn s3_test_bucket_endpoint() {
+ let builder = AmazonS3Builder::new()
+ .with_endpoint("http://some.host:1234")
+ .with_bucket_name("foo")
+ .build()
+ .unwrap();
+ assert_eq!(
+ builder.client.config.bucket_endpoint,
+ "http://some.host:1234/foo"
+ );
+
+ let builder = AmazonS3Builder::new()
+ .with_endpoint("http://some.host:1234/")
+ .with_bucket_name("foo")
+ .build()
+ .unwrap();
+ assert_eq!(
+ builder.client.config.bucket_endpoint,
+ "http://some.host:1234/foo"
+ );
+ }
+
#[test]
fn s3_test_urls() {
let mut builder = AmazonS3Builder::new();