File: storage.txt

package info (click to toggle)
python-django 1.2.3-3%2Bsqueeze15
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 29,720 kB
  • ctags: 21,538
  • sloc: python: 101,631; xml: 574; makefile: 149; sh: 121; sql: 7
file content (52 lines) | stat: -rw-r--r-- 1,585 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
File storage API
================

``Storage.exists(name)``
~~~~~~~~~~~~~~~~~~~~~~~~

``True`` if a file exists given some ``name``.

``Storage.path(name)``
~~~~~~~~~~~~~~~~~~~~~~

The local filesystem path where the file can be opened using Python's standard
``open()``. For storage systems that aren't accessible from the local
filesystem, this will raise ``NotImplementedError`` instead.

``Storage.size(name)``
~~~~~~~~~~~~~~~~~~~~~~

Returns the total size, in bytes, of the file referenced by ``name``.

``Storage.url(name)``
~~~~~~~~~~~~~~~~~~~~~

Returns the URL where the contents of the file referenced by ``name`` can be
accessed.

``Storage.open(name, mode='rb')``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Opens the file given by ``name``. Note that although the returned file is
guaranteed to be a ``File`` object, it might actually be some subclass. In the
case of remote file storage this means that reading/writing could be quite slow,
so be warned.

``Storage.save(name, content)``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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 ``content`` argument must be an instance of
:class:`django.core.files.File` or of a subclass of
:class:`~django.core.files.File`.

``Storage.delete(name)``
~~~~~~~~~~~~~~~~~~~~~~~~

Deletes the file referenced by ``name``. This method won't raise an exception if
the file doesn't exist.