richleland / django-cumulus (http://packages.python.org/django-cumulus/)

An interface to Rackspace Cloud Files through Django.

Clone this repository (size: 76.4 KB): HTTPS / SSH
$ hg clone http://code.richleland.com/django-cumulus

Changed (Δ241 bytes):

raw changeset »

cumulus/storage.py (8 lines added, 1 lines removed)

Up to file-list cumulus/storage.py:

1
import mimetypes
1
2
from django.conf import settings
2
3
from django.core.exceptions import ImproperlyConfigured
3
4
from django.core.files import File
@@ -110,11 +111,17 @@ class CloudFilesStorage(Storage):
110
111
        """
111
112
        content.open()
112
113
        cloud_obj = self.container.create_object(name)
113
        cloud_obj.size = content.file.size
114
        if hasattr(content.file, 'size'):
115
            cloud_obj.size = content.file.size
116
        else:
117
            cloud_obj.size = content.size
114
118
        # If the content type is available, pass it in directly rather than
115
119
        # getting the cloud object to try to guess.
116
120
        if hasattr(content.file, 'content_type'):
117
121
            cloud_obj.content_type = content.file.content_type
122
        else:
123
            mime_type, encoding = mimetypes.guess_type(name)
124
            cloud_obj.content_type = mime_type
118
125
        cloud_obj.send(content)
119
126
        content.close()
120
127
        return name