Commits

Chris Beaven committed 9422f4b

Don't rely on the file having a content_type already set (use mimetypes.guess_type if it's not)

  • Participants
  • Parent commits 0adc1b8

Comments (0)

Files changed (1)

File backends/mosso.py

 Created by Rich Leland <rich@richleland.com>.
 """
 from django.conf import settings
+from django.core.exceptions import ImproperlyConfigured
 from django.core.files import File
 from django.core.files.storage import Storage
-from django.core.exceptions import ImproperlyConfigured
 from django.utils.text import get_valid_filename
+import mimetypes
 
 
 try:
         else:
             content_str = content.read()
         cloud_obj = self.container.create_object(name)
-        cloud_obj.content_type = content.file.content_type
+        if hasattr(content.file, 'content_type'):
+            content_type = content.file.content_type
+        else:
+            content_type = mimetypes.guess_type(name)[0]
+        cloud_obj.content_type = content_type
         cloud_obj.send(content_str)
         content.close()
         return name