mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
import: Always set a valid content-type for S3 backend.
The octet-stream content type is potentially under-specified, but it's better than potentially submitting None and increases consistency of this part of the codebase.
This commit is contained in:
@@ -601,6 +601,12 @@ def import_uploads(import_dir: Path, processing_avatars: bool=False,
|
||||
content_type = record.get("content_type")
|
||||
if content_type is None:
|
||||
content_type = guess_type(record['s3_path'])[0]
|
||||
if content_type is None:
|
||||
# This is the default for unknown data. Note that
|
||||
# for `.original` files, this is the value we'll
|
||||
# set; that is OK, because those are never served
|
||||
# directly anyway.
|
||||
content_type = 'application/octet-stream'
|
||||
headers = {'Content-Type': content_type} # type: Dict[str, Any]
|
||||
|
||||
key.set_contents_from_filename(os.path.join(import_dir, record['path']), headers=headers)
|
||||
|
||||
Reference in New Issue
Block a user