mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
s3: Support non-AWS S3 providers which do not support request checksums.
(cherry picked from commit aeed907c50)
This commit is contained in:
committed by
Tim Abbott
parent
4f86630faa
commit
b7e38f4dd6
@@ -56,6 +56,9 @@ if settings.S3_SKIP_PROXY is True: # nocoverage
|
||||
def get_bucket(bucket_name: str, authed: bool = True) -> "Bucket":
|
||||
import boto3
|
||||
|
||||
checksum: Literal["when_required", "when_supported"] = (
|
||||
"when_required" if settings.S3_SKIP_CHECKSUM else "when_supported"
|
||||
)
|
||||
return boto3.resource(
|
||||
"s3",
|
||||
aws_access_key_id=settings.S3_KEY if authed else None,
|
||||
@@ -65,6 +68,7 @@ def get_bucket(bucket_name: str, authed: bool = True) -> "Bucket":
|
||||
config=Config(
|
||||
signature_version=None if authed else botocore.UNSIGNED,
|
||||
s3={"addressing_style": settings.S3_ADDRESSING_STYLE},
|
||||
request_checksum_calculation=checksum,
|
||||
),
|
||||
).Bucket(bucket_name)
|
||||
|
||||
|
||||
@@ -77,4 +77,6 @@ class Command(BaseCommand):
|
||||
env_vars["AWS_REGION"] = boto3.client("s3").meta.region_name
|
||||
else:
|
||||
env_vars["AWS_REGION"] = settings.S3_REGION
|
||||
if settings.S3_SKIP_CHECKSUM:
|
||||
env_vars["AWS_REQUEST_CHECKSUM_CALCULATION"] = "when_required"
|
||||
os.execvpe("tusd", tusd_args, env_vars)
|
||||
|
||||
Reference in New Issue
Block a user