mirror of https://github.com/zulip/zulip.git
upload: Content-type is always defined.
This commit is contained in:
parent
17fb23746f
commit
2eaf098c5d
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue