~ubuntu-branches/debian/squeeze/python-django/squeeze

« back to all changes in this revision

Viewing changes to docs/topics/http/file-uploads.txt

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb, Chris Lamb, David Spreen, Sandro Tosi
  • Date: 2008-11-19 21:31:00 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081119213100-gp0lqhxl1qxa6dgl
Tags: 1.0.2-1
[ Chris Lamb ]
* New upstream bugfix release. Closes: #505783
* Add myself to Uploaders with ACK from Brett.

[ David Spreen ]
* Remove python-pysqlite2 from Recommends because Python 2.5 includes
  sqlite library used by Django. Closes: 497886

[ Sandro Tosi ]
* debian/control
  - switch Vcs-Browser field to viewsvn

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
.. versionadded:: 1.0
10
10
 
11
 
Most Web sites wouldn't be complete without a way to upload files. When Django
12
 
handles a file upload, the file data ends up placed in ``request.FILES`` (for
13
 
more on the ``request`` object see the documentation for :ref:`request and
14
 
response objects <ref-request-response>`). This document explains how files are
15
 
stored on disk and in memory, and how to customize the default behavior.
 
11
When Django handles a file upload, the file data ends up placed in
 
12
``request.FILES`` (for more on the ``request`` object see the documentation for
 
13
:ref:`request and response objects <ref-request-response>`). This document
 
14
explains how files are stored on disk and in memory, and how to customize the
 
15
default behavior.
16
16
 
17
17
Basic file uploads
18
18
==================
94
94
        destination = open('some/file/name.txt', 'wb+')
95
95
        for chunk in f.chunks():
96
96
            destination.write(chunk)
 
97
        destination.close()
97
98
 
98
99
Looping over ``UploadedFile.chunks()`` instead of using ``read()`` ensures that
99
100
large files don't overwhelm your system's memory.
131
132
 
132
133
    :setting:`FILE_UPLOAD_TEMP_DIR`
133
134
        The directory where uploaded files larger than
134
 
        :setting:`FILE_UPLOAD_TEMP_DIR` will be stored.
 
135
        :setting:`FILE_UPLOAD_MAX_MEMORY_SIZE` will be stored.
135
136
 
136
137
        Defaults to your system's standard temporary directory (i.e. ``/tmp`` on
137
138
        most Unix-like systems).
152
153
            ``0`` is very important: it indicates an octal number, which is the
153
154
            way that modes must be specified. If you try to use ``644``, you'll
154
155
            get totally incorrect behavior.
155
 
            
156
 
            **Always prefix the mode with a ``0``.**
 
156
 
 
157
            **Always prefix the mode with a 0.**
157
158
 
158
159
    :setting:`FILE_UPLOAD_HANDLERS`
159
160
        The actual handlers for uploaded files. Changing this setting allows