upload: Ensure that we always have a content-type.

Old uploads are stored without a content-type, and guess_type may not
provide a type for them.
This commit is contained in:
Alex Vandiver
2025-07-29 14:21:04 +00:00
committed by Tim Abbott
parent 1bc7696c24
commit 0c6b3373be

View File

@@ -131,8 +131,7 @@ def serve_local(
return HttpResponseNotFound("<p>File not found</p>")
if content_type is None:
content_type = guess_type(filename)[0]
assert content_type is not None
content_type = guess_type(filename)[0] or "application/octet-stream"
download = force_download or bare_content_type(content_type) not in INLINE_MIME_TYPES
if settings.DEVELOPMENT: