diff options
| author | Honza Král <Honza.Kral@gmail.com> | 2013-02-23 08:04:41 -0800 |
|---|---|---|
| committer | Honza Král <Honza.Kral@gmail.com> | 2013-02-23 08:04:41 -0800 |
| commit | 129d2e8f85b1e80f10ec967b72ba0af9b239019f (patch) | |
| tree | 25efef264d89b33ebc6a8bd59ececeb314910c30 /django | |
| parent | 8c1cc4b3b04f639ae40bc806380bc4a9dd568eb0 (diff) | |
| parent | 664855b74e1f417384dc7aef35a3df5f86db52d6 (diff) | |
Merge pull request #775 from HiddenData/ticket-18899
Fixed #18899 -- FileSystemStorage.save should support any file-like objects
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/files/storage.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/core/files/storage.py b/django/core/files/storage.py index 0b623fe7c2..89caf3675d 100644 --- a/django/core/files/storage.py +++ b/django/core/files/storage.py @@ -37,13 +37,17 @@ class Storage(object): def save(self, name, content): """ - Saves new content to the file specified by name. The content should be a - proper File object, ready to be read from the beginning. + Saves new content to the file specified by name. The content should be + a proper File object or any python file-like object, ready to be read + from the beginning. """ # Get the proper name for the file, as it will actually be saved. if name is None: name = content.name + if not hasattr(content, 'chunks'): + content = File(content) + name = self.get_available_name(name) name = self._save(name, content) |
