From df3edceacddfc820a23bb01a2ae8622f125803d1 Mon Sep 17 00:00:00 2001 From: John Tordoff <> Date: Tue, 18 Jul 2023 09:17:06 -0400 Subject: [PATCH] make get bucket names use the correct calling format --- addons/s3/utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/s3/utils.py b/addons/s3/utils.py index 750c81f8b38..b2660a54f68 100644 --- a/addons/s3/utils.py +++ b/addons/s3/utils.py @@ -131,7 +131,14 @@ def get_bucket_location_or_error(access_key, secret_key, bucket_name): def get_bucket_prefixes(access_key, secret_key, prefix, bucket_name): - bucket = S3Connection(access_key, secret_key).get_bucket(bucket_name) # Don't use OrdinaryCallingFormat + connection = S3Connection(access_key, secret_key) + + if bucket_name != bucket_name.lower() or '.' in bucket_name: + # Must use ordinary calling format for mIxEdCaSe or `.` containing bucket names + # otherwise use the default as it handles bucket outside of the US + connection.calling_format = OrdinaryCallingFormat() + + bucket = connection.get_bucket(bucket_name) folders = [] for key in bucket.list(delimiter='/', prefix=prefix):