From 05457817647368be4b019314fcc655445a5b4c0c Mon Sep 17 00:00:00 2001 From: yukihira1992 Date: Thu, 29 Aug 2019 01:17:07 +0900 Subject: Fixed #30736 -- Added Storage.get_alternative_name() to allow customization. --- docs/ref/files/storage.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'docs/ref') diff --git a/docs/ref/files/storage.txt b/docs/ref/files/storage.txt index 2a82402fac..0724a0cda1 100644 --- a/docs/ref/files/storage.txt +++ b/docs/ref/files/storage.txt @@ -105,6 +105,12 @@ The ``Storage`` class If :setting:`USE_TZ` is ``True``, returns an aware ``datetime``, otherwise returns a naive ``datetime`` in the local timezone. + .. method:: get_alternative_name(file_root, file_ext) + + Returns an alternative filename based on the ``file_root`` and + ``file_ext`` parameters, an underscore plus a random 7 character + alphanumeric string is appended to the filename before the extension. + .. method:: get_available_name(name, max_length=None) Returns a filename based on the ``name`` parameter that's free and @@ -116,9 +122,8 @@ The ``Storage`` class :exc:`SuspiciousFileOperation ` 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. + If a file with ``name`` already exists, :meth:`get_alternative_name` is + called to obtain an alternative name. .. method:: get_created_time(name) -- cgit v1.3