From 9f2daeee4506651060118161826a25b372dc3da1 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 27 May 2021 23:23:07 -0700 Subject: [PATCH] upload: Use get_public_upload_url for export tarballs too. This deduplicates the code so that we now just have one function for constructing S3 URLs. --- zerver/lib/upload.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/zerver/lib/upload.py b/zerver/lib/upload.py index 8296eaeb60..66469a57ce 100644 --- a/zerver/lib/upload.py +++ b/zerver/lib/upload.py @@ -679,22 +679,7 @@ class S3UploadBackend(ZulipUploadBackend): key.upload_file(tarball_path, Callback=percent_callback) - session = botocore.session.get_session() - config = Config(signature_version=botocore.UNSIGNED) - - public_url = session.create_client( - "s3", - region_name=settings.S3_REGION, - endpoint_url=settings.S3_ENDPOINT_URL, - config=config, - ).generate_presigned_url( - "get_object", - Params={ - "Bucket": self.avatar_bucket.name, - "Key": key.key, - }, - ExpiresIn=0, - ) + public_url = self.get_public_upload_url(key.key) return public_url def delete_export_tarball(self, export_path: str) -> Optional[str]: