Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

upload: Content-type is always defined.

Alex Vandiver2eaf098c5db9
diff --git a/zerver/lib/upload/__init__.py b/zerver/lib/upload/__init__.py
index 70d8ea08c38..35e3d7a117c 100644
--- a/zerver/lib/upload/__init__.py
+++ b/zerver/lib/upload/__init__.py
@@ -119,7 +119,7 @@ def sanitize_name(value: str) -> str:
def upload_message_attachment(
uploaded_file_name: str,
uploaded_file_size: int,
- content_type: Optional[str],
+ content_type: str,
file_data: bytes,
user_profile: UserProfile,
target_realm: Optional[Realm] = None,
diff --git a/zerver/lib/upload/base.py b/zerver/lib/upload/base.py
index ad7007c9240..b679e9cb8f5 100644
--- a/zerver/lib/upload/base.py
+++ b/zerver/lib/upload/base.py
@@ -38,7 +38,7 @@ class ZulipUploadBackend:
self,
path_id: str,
uploaded_file_size: int,
- content_type: Optional[str],
+ content_type: str,
file_data: bytes,
user_profile: UserProfile,
target_realm: Realm,
diff --git a/zerver/lib/upload/local.py b/zerver/lib/upload/local.py
index 673ae6c38e1..10c3ed2ed11 100644
--- a/zerver/lib/upload/local.py
+++ b/zerver/lib/upload/local.py
@@ -81,7 +81,7 @@ class LocalUploadBackend(ZulipUploadBackend):
self,
path_id: str,
uploaded_file_size: int,
- content_type: Optional[str],
+ content_type: str,
file_data: bytes,
user_profile: UserProfile,
target_realm: Realm,
diff --git a/zerver/lib/upload/s3.py b/zerver/lib/upload/s3.py
index d242398069b..80f90b00b7d 100644
--- a/zerver/lib/upload/s3.py
+++ b/zerver/lib/upload/s3.py
@@ -205,7 +205,7 @@ class S3UploadBackend(ZulipUploadBackend):
self,
path_id: str,
uploaded_file_size: int,
- content_type: Optional[str],
+ content_type: str,
file_data: bytes,
user_profile: UserProfile,
target_realm: Realm,
diff --git a/zerver/tests/test_upload_s3.py b/zerver/tests/test_upload_s3.py
index 309958acea5..186c57dc085 100644
--- a/zerver/tests/test_upload_s3.py
+++ b/zerver/tests/test_upload_s3.py
@@ -95,18 +95,6 @@ class S3Test(ZulipTestCase):
# Ensure the correct realm id of the target realm is used instead of the bot's realm.
self.assertTrue(url.startswith(f"/user_uploads/{zulip_realm.id}/"))
- @use_s3_backend
- def test_upload_message_attachment_s3_with_undefined_content_type(self) -> None:
- bucket = create_s3_buckets(settings.S3_AUTH_UPLOADS_BUCKET)[0]
-
- user_profile = self.example_user("hamlet")
- url = upload_message_attachment("dummy.txt", len(b"zulip!"), None, b"zulip!", user_profile)
-
- path_id = re.sub(r"/user_uploads/", "", url)
- self.assertEqual(b"zulip!", bucket.Object(path_id).get()["Body"].read())
- uploaded_file = Attachment.objects.get(owner=user_profile, path_id=path_id)
- self.assert_length(b"zulip!", uploaded_file.size)
-
@use_s3_backend
def test_delete_message_attachment(self) -> None:
bucket = create_s3_buckets(settings.S3_AUTH_UPLOADS_BUCKET)[0]