s3: Add a setting for S3 addressing style.

This controls if boto3 attempts to use
`https://bucketname.endpointname/` or `https://endpointname/bucket/`
as its prefix.  See
https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html

Fixes: #28424.
This commit is contained in:
Alex Vandiver 2024-01-03 20:27:53 +00:00 committed by Tim Abbott
parent 3aea67a8ed
commit 75d6f35069
3 changed files with 3 additions and 0 deletions

View File

@ -65,6 +65,7 @@ def get_bucket(bucket_name: str, authed: bool = True) -> Bucket:
endpoint_url=settings.S3_ENDPOINT_URL,
config=Config(
signature_version=None if authed else botocore.UNSIGNED,
s3={"addressing_style": settings.S3_ADDRESSING_STYLE},
),
).Bucket(bucket_name)

View File

@ -148,6 +148,7 @@ S3_AVATAR_BUCKET = ""
S3_AUTH_UPLOADS_BUCKET = ""
S3_REGION: Optional[str] = None
S3_ENDPOINT_URL: Optional[str] = None
S3_ADDRESSING_STYLE: Literal["auto", "virtual", "path"] = "auto"
S3_SKIP_PROXY = True
S3_UPLOADS_STORAGE_CLASS: Literal[
"GLACIER_IR",

View File

@ -788,6 +788,7 @@ LOCAL_UPLOADS_DIR = "/home/zulip/uploads"
# S3_AVATAR_BUCKET = ""
# S3_REGION = None
# S3_ENDPOINT_URL = None
# S3_ADDRESSING_STYLE = "auto"
# S3_SKIP_PROXY = True
# S3_UPLOADS_STORAGE_CLASS = "STANDARD"