Ticket #8912: storage_save_8975.diff
File storage_save_8975.diff, 3.1 KB (added by , 16 years ago) |
---|
-
django/db/models/fields/files.py
71 71 72 72 def save(self, name, content, save=True): 73 73 name = self.field.generate_filename(self.instance, name) 74 self._name = self.storage.save(name, content )74 self._name = self.storage.save(name, content, save) 75 75 setattr(self.instance, self.field.name, self.name) 76 76 77 77 # Update the filesize cache -
django/core/files/storage.py
32 32 file.__class__ = type(mixin.__name__, (mixin, file.__class__), {}) 33 33 return file 34 34 35 def save(self, name, content ):35 def save(self, name, content, save=True): 36 36 """ 37 37 Saves new content to the file specified by name. The content should be a 38 38 proper File object, ready to be read from the beginning. … … 42 42 name = content.name 43 43 44 44 name = self.get_available_name(name) 45 name = self._save(name, content )45 name = self._save(name, content, save) 46 46 47 47 # Store filenames with forward slashes, even on Windows 48 48 return force_unicode(name.replace('\\', '/')) -
docs/howto/custom-file-storage.txt
58 58 you'll want to return some subclass here that implements logic specific to the 59 59 backend storage system. 60 60 61 ``_save(name, content )``61 ``_save(name, content, save=True)`` 62 62 ~~~~~~~~~~~~~~~~~~~~~~~~ 63 63 64 64 Called by ``Storage.save()``. The ``name`` will already have gone through 65 65 ``get_valid_name()`` and ``get_available_name()``, and the ``content`` will be a 66 ``File`` object itself. No return value is expected. 66 ``File`` object itself. If the ``save`` argument is false, then the content 67 should not be saved to backend. The actual name of the destination file is expected 68 as a return value, regardless of whether the save argument is True or False. 67 69 68 70 ``get_valid_name(name)`` 69 71 ------------------------ -
docs/ref/files/storage.txt
34 34 case of remote file storage this means that reading/writing could be quite slow, 35 35 so be warned. 36 36 37 ``Storage.save(name, content )``37 ``Storage.save(name, content, save=True)`` 38 38 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 39 39 40 40 Saves a new file using the storage system, preferably with the name specified. … … 46 46 :class:`django.db.files.File` or of a subclass of 47 47 :class:`~django.db.files.File`. 48 48 49 If the save argument is false, the proper ``name`` will still be returned, but 50 the file won't actually be saved to the backend. 51 49 52 ``Storage.delete(name)`` 50 53 ~~~~~~~~~~~~~~~~~~~~~~~~ 51 54