diff options
| author | Francesco Panico <panico.francesco@gmail.com> | 2022-11-11 07:17:49 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-01-10 10:56:59 +0100 |
| commit | 72efd840a8cb6ee35a3732d8bb434e7361970b3c (patch) | |
| tree | 8379ee124d0c278b593b3dc2487ab8e44ad64c30 /docs | |
| parent | 04fdf719331dde6b0f4e7cdc445be4d4278f3ec4 (diff) | |
Fixed #34110 -- Added in-memory file storage.
Thanks Paolo Melchiorre, Carlton Gibson, and Mariusz Felisiak for
reviews.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/files/storage.txt | 33 | ||||
| -rw-r--r-- | docs/releases/4.2.txt | 6 | ||||
| -rw-r--r-- | docs/topics/testing/overview.txt | 9 |
3 files changed, 48 insertions, 0 deletions
diff --git a/docs/ref/files/storage.txt b/docs/ref/files/storage.txt index c09a46fa64..fa79a4f91a 100644 --- a/docs/ref/files/storage.txt +++ b/docs/ref/files/storage.txt @@ -74,6 +74,39 @@ The ``FileSystemStorage`` class time of the last metadata change, and on others (like Windows), it's the creation time of the file. +The ``InMemoryStorage`` class +============================= + +.. versionadded:: 4.2 + +.. class:: InMemoryStorage(location=None, base_url=None, file_permissions_mode=None, directory_permissions_mode=None) + + The :class:`~django.core.files.storage.InMemoryStorage` class implements + a memory-based file storage. It has no persistence, but can be useful for + speeding up tests by avoiding disk access. + + .. attribute:: location + + Absolute path to the directory name assigned to files. Defaults to the + value of your :setting:`MEDIA_ROOT` setting. + + .. attribute:: base_url + + URL that serves the files stored at this location. + Defaults to the value of your :setting:`MEDIA_URL` setting. + + .. attribute:: file_permissions_mode + + The file system permissions assigned to files, provided for + compatibility with ``FileSystemStorage``. Defaults to + :setting:`FILE_UPLOAD_PERMISSIONS`. + + .. attribute:: directory_permissions_mode + + The file system permissions assigned to directories, provided for + compatibility with ``FileSystemStorage``. Defaults to + :setting:`FILE_UPLOAD_DIRECTORY_PERMISSIONS`. + The ``Storage`` class ===================== diff --git a/docs/releases/4.2.txt b/docs/releases/4.2.txt index 68392161e3..c04d0ab57c 100644 --- a/docs/releases/4.2.txt +++ b/docs/releases/4.2.txt @@ -85,6 +85,12 @@ The Breach (HTB) paper`_. .. _Heal The Breach (HTB) paper: https://ieeexplore.ieee.org/document/9754554 +In-memory file storage +---------------------- + +The new ``django.core.files.storage.InMemoryStorage`` class provides a +non-persistent storage useful for speeding up tests by avoiding disk access. + Minor features -------------- diff --git a/docs/topics/testing/overview.txt b/docs/topics/testing/overview.txt index 750ecb5dc2..e37cf23737 100644 --- a/docs/topics/testing/overview.txt +++ b/docs/topics/testing/overview.txt @@ -366,3 +366,12 @@ Preserving the test database The :option:`test --keepdb` option preserves the test database between test runs. It skips the create and destroy actions which can greatly decrease the time to run tests. + +Avoiding disk access for media files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 4.2 + +The :class:`~django.core.files.storage.InMemoryStorage` is a convenient way to +prevent disk access for media files. All data is kept in memory, then it gets +discarded after tests run. |
