Commits

Marco Pensallorto  committed 2854958

Fixed mimetype when uploading a file to the remote resource

  • Participants
  • Parent commits 732da5c

Comments (0)

Files changed (1)

File storages/backends/mosso.py

     from StringIO import StringIO
 
 import os
+import mimetypes
+
 from django.conf import settings
 from django.core.exceptions import ImproperlyConfigured
 from django.core.files import File
         cloud_obj.size = content.size
 
         content.open()
-        # If the content type is available, pass it in directly rather than
-        # getting the cloud object to try to guess.
-        if hasattr(content.file, 'content_type'):
-            cloud_obj.content_type = content.file.content_type
+
+        # [MW] Determine mime-type by guessing
+        # (patch taken from s3 backend.)
+        cloud_obj.content_type = \
+            mimetypes.guess_type(name)[0] or "application/x-octet-stream"
+
         cloud_obj.send(content)
         content.close()
         return name