summaryrefslogtreecommitdiff
path: root/docs/ref/files/storage.txt
diff options
context:
space:
mode:
authorPavel Shpilev <pavel.shpilev@medibank.com.au>2014-10-15 18:42:06 +1100
committerTim Graham <timograham@gmail.com>2015-01-12 09:09:18 -0500
commita7c256cb5491bf2a77abdff01638239db5bfd9d5 (patch)
tree3b3cd98b0f2f42efd989ae9dd9ab3dba473d972a /docs/ref/files/storage.txt
parentb5c1a85b50c709770b8e98aeecfeb8e81ca29dcf (diff)
Fixed #9893 -- Allowed using a field's max_length in the Storage.
Diffstat (limited to 'docs/ref/files/storage.txt')
-rw-r--r--docs/ref/files/storage.txt20
1 files changed, 18 insertions, 2 deletions
diff --git a/docs/ref/files/storage.txt b/docs/ref/files/storage.txt
index a16b6b6c9d..88da416dcf 100644
--- a/docs/ref/files/storage.txt
+++ b/docs/ref/files/storage.txt
@@ -114,12 +114,17 @@ The Storage Class
in the storage system, or ``False`` if the name is available for a new
file.
- .. method:: get_available_name(name)
+ .. method:: get_available_name(name, max_length=None)
Returns a filename based on the ``name`` parameter that's free and
available for new content to be written to on the target storage
system.
+ The length of the filename will not exceed ``max_length``, if provided.
+ If a free unique filename cannot be found, a
+ :exc:`SuspiciousFileOperation
+ <django.core.exceptions.SuspiciousOperation>` exception will be raised.
+
If a file with ``name`` already exists, an underscore plus a random
7 character alphanumeric string is appended to the filename before
the extension.
@@ -133,6 +138,10 @@ The Storage Class
attack. This change was also made in Django 1.6.6, 1.5.9, and
1.4.14.
+ .. versionchanged:: 1.8
+
+ The ``max_length`` argument was added.
+
.. method:: get_valid_name(name)
Returns a filename based on the ``name`` parameter that's suitable
@@ -165,17 +174,24 @@ The Storage Class
standard ``open()``. For storage systems that aren't accessible from
the local filesystem, this will raise ``NotImplementedError`` instead.
- .. method:: save(name, content)
+ .. method:: save(name, content, max_length=None)
Saves a new file using the storage system, preferably with the name
specified. If there already exists a file with this name ``name``, the
storage system may modify the filename as necessary to get a unique
name. The actual name of the stored file will be returned.
+ The ``max_length`` argument is passed along to
+ :meth:`get_available_name`.
+
The ``content`` argument must be an instance of
:class:`django.core.files.File` or of a subclass of
:class:`~django.core.files.File`.
+ .. versionchanged:: 1.8
+
+ The ``max_length`` argument was added.
+
.. method:: size(name)
Returns the total size, in bytes, of the file referenced by ``name``.