Ticket #19310: custom-file-storage.txt.diff

File custom-file-storage.txt.diff, 1.8 KB (added by ClaesBas, 5 years ago)
  • docs/howto/custom-file-storage.txt

    diff --git a/docs/howto/custom-file-storage.txt b/docs/howto/custom-file-storage.txt
    index 5f1dae1..54400e6 100644
    a b Your custom storage system may override any of the storage methods explained in 
    4646You'll also usually want to use hooks specifically designed for custom storage
    4747objects. These are:
    49 ``_open(name, mode='rb')``
    50 ~~~~~~~~~~~~~~~~~~~~~~~~~~
     49.. method:: _open(name, mode='rb')
    uses to open the file. This must return a ``File`` object, though in most cases, 
    5655you'll want to return some subclass here that implements logic specific to the
    5756backend storage system.
    59 ``_save(name, content)``
    60 ~~~~~~~~~~~~~~~~~~~~~~~~
     58.. method:: _save(name, content)
    6260Called by ``Storage.save()``. The ``name`` will already have gone through
    6361``get_valid_name()`` and ``get_available_name()``, and the ``content`` will be a
    Should return the actual name of name of the file saved (usually the ``name`` 
    6765passed in, but if the storage needs to change the file name return the new name
    70 ``get_valid_name(name)``
    71 ~~~~~~~~~~~~~~~~~~~~~~~~
     68.. method:: get_valid_name(name)
    7371Returns a filename suitable for use with the underlying storage system. The
    7472``name`` argument passed to this method is the original filename sent to the
    how non-standard characters are converted to safe filenames. 
    7876The code provided on ``Storage`` retains only alpha-numeric characters, periods
    7977and underscores from the original filename, removing everything else.
    81 ``get_available_name(name)``
    82 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     79.. method:: get_available_name(name)
    8481Returns a filename that is available in the storage mechanism, possibly taking
    8582the provided filename into account. The ``name`` argument passed to this method
Back to Top