29
29
The FileSystemStorage Class
30
30
---------------------------
32
.. class:: FileSystemStorage
32
.. class:: FileSystemStorage([location=None, base_url=None, file_permissions_mode=None, directory_permissions_mode=None])
34
34
The :class:`~django.core.files.storage.FileSystemStorage` class implements
35
35
basic file storage on a local filesystem. It inherits from
36
36
:class:`~django.core.files.storage.Storage` and provides implementations
37
37
for all the public methods thereof.
39
.. attribute:: location
41
Absolute path to the directory that will hold the files.
42
Defaults to the value of your :setting:`MEDIA_ROOT` setting.
44
.. attribute:: base_url
46
URL that serves the files stored at this location.
47
Defaults to the value of your :setting:`MEDIA_URL` setting.
49
.. attribute:: file_permissions_mode
51
The file system permissions that the file will receive when it is
52
saved. Defaults to :setting:`FILE_UPLOAD_PERMISSIONS`.
56
The ``file_permissions_mode`` attribute was added. Previously files
57
always received :setting:`FILE_UPLOAD_PERMISSIONS` permissions.
59
.. attribute:: directory_permissions_mode
61
The file system permissions that the directory will receive when it is
62
saved. Defaults to :setting:`FILE_UPLOAD_DIRECTORY_PERMISSIONS`.
66
The ``directory_permissions_mode`` attribute was added. Previously
67
directories always received
68
:setting:`FILE_UPLOAD_DIRECTORY_PERMISSIONS` permissions.
41
72
The ``FileSystemStorage.delete()`` method will not raise
81
112
available for new content to be written to on the target storage
84
.. versionchanged:: 1.6.6
115
.. versionchanged:: 1.7
86
117
If a file with ``name`` already exists, an underscore plus a random 7
87
118
character alphanumeric string is appended to the filename before the
90
121
Previously, an underscore followed by a number (e.g. ``"_1"``, ``"_2"``,
91
etc.) was appended to the filename until an avaible name in the
122
etc.) was appended to the filename until an available name in the
92
123
destination directory was found. A malicious user could exploit this
93
124
deterministic algorithm to create a denial-of-service attack. This
94
change was also made in Django 1.5.9 and 1.4.14.
125
change was also made in Django 1.6.6, 1.5.9, and 1.4.14.
96
127
.. method:: get_valid_name(name)