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:
Tim Abbott
2018-11-06 13:03:14 -08:00
parent 81a4c846f4
commit 1bf385e35f

View File

@@ -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)