changeset 29:20d4cf433704

Improve media attachment MIME detection, and fallback to JPEG on fail
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 19 Apr 2023 12:48:58 -0700
parents 69a6a8c9d33d
children 53de06c2f97d
files silorider/silos/base.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/silorider/silos/base.py	Wed Apr 19 12:48:25 2023 -0700
+++ b/silorider/silos/base.py	Wed Apr 19 12:48:58 2023 -0700
@@ -133,8 +133,9 @@
 
 def _do_upload_silo_media(url, callback):
     logger.debug("Downloading %s for upload to silo..." % url)
-    mt, enc = mimetypes.guess_type(url)
+    mt, enc = mimetypes.guess_type(url, strict=False)
     if not mt:
+        logger.debug("Can't guess MIME type, defaulting to jpg")
         mt = mimetypes.common_types['.jpg']
 
     ext = mimetypes.guess_extension(mt) or '.jpg'