mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
import: Avoid sending a content-type of None to S3.
The previous logic was incorrect, in that if `content_type` was set to None (which happens with Slack/HipChat export, among other things), then we wouldn't run the `guess_type` logic to auto-detect the Content-Type to send to S3.
This commit is contained in:
@@ -603,7 +603,9 @@ def import_uploads_s3(bucket_name: str, import_dir: Path, processing_avatars: bo
|
||||
key.set_metadata("realm_id", str(record['realm_id']))
|
||||
|
||||
# Zulip exports will always have a content-type, but third-party exports might not.
|
||||
content_type = record.get("content_type", guess_type(record['s3_path'])[0])
|
||||
content_type = record.get("content_type")
|
||||
if content_type is None:
|
||||
content_type = guess_type(record['s3_path'])[0]
|
||||
headers = {'Content-Type': content_type}
|
||||
|
||||
key.set_contents_from_filename(os.path.join(import_dir, record['path']), headers=headers)
|
||||
|
Reference in New Issue
Block a user