1
0
mirror of https://github.com/django/django.git synced 2025-10-29 00:26:07 +00:00

#18899 FileSystemStorage.save should support any file-like objects

This commit is contained in:
Marcin Biernat
2013-02-23 13:42:04 +01:00
parent 7ec2a21be1
commit 664855b74e
2 changed files with 36 additions and 2 deletions

View File

@@ -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)