1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #35326 -- Added allow_overwrite parameter to FileSystemStorage.

This commit is contained in:
Ben Cail
2024-03-26 11:25:29 -04:00
committed by Sarah Boyce
parent 6c48eed238
commit 0b33a3abc2
5 changed files with 157 additions and 15 deletions

View File

@@ -79,6 +79,9 @@ details on these changes.
* The ``check`` keyword argument of ``CheckConstraint`` will be removed.
* The ``OS_OPEN_FLAGS`` attribute of
:class:`~django.core.files.storage.FileSystemStorage` will be removed.
.. _deprecation-removed-in-5.1:
5.1

View File

@@ -28,7 +28,7 @@ Django provides convenient ways to access the default storage class:
The ``FileSystemStorage`` class
===============================
.. class:: FileSystemStorage(location=None, base_url=None, file_permissions_mode=None, directory_permissions_mode=None)
.. class:: FileSystemStorage(location=None, base_url=None, file_permissions_mode=None, directory_permissions_mode=None, allow_overwrite=False)
The :class:`~django.core.files.storage.FileSystemStorage` class implements
basic file storage on a local filesystem. It inherits from
@@ -60,6 +60,13 @@ The ``FileSystemStorage`` class
The file system permissions that the directory will receive when it is
saved. Defaults to :setting:`FILE_UPLOAD_DIRECTORY_PERMISSIONS`.
.. attribute:: allow_overwrite
.. versionadded:: 5.1
Flag to control allowing saving a new file over an existing one.
Defaults to ``False``.
.. method:: get_created_time(name)
Returns a :class:`~datetime.datetime` of the system's ctime, i.e.

View File

@@ -210,7 +210,10 @@ Error Reporting
File Storage
~~~~~~~~~~~~
* ...
* The :attr:`~django.core.files.storage.FileSystemStorage.allow_overwrite`
parameter has been added to
:class:`~django.core.files.storage.FileSystemStorage`, to allow saving new
files over existing ones.
File Uploads
~~~~~~~~~~~~
@@ -467,6 +470,12 @@ Miscellaneous
* The ``check`` keyword argument of ``CheckConstraint`` is deprecated in favor
of ``condition``.
* The undocumented ``OS_OPEN_FLAGS`` property of
:class:`~django.core.files.storage.FileSystemStorage` has been deprecated.
To allow overwriting files in storage, set the new
:attr:`~django.core.files.storage.FileSystemStorage.allow_overwrite` option
to ``True`` instead.
Features removed in 5.1
=======================