Django

Code

Show
Ignore:
Timestamp:
07/01/08 10:10:51 (3 months ago)
Author:
jacob
Message:

Fixed #2070: refactored Django's file upload capabilities.

A description of the new features can be found in the new upload handling documentation; the executive summary is that Django will now happily handle uploads of large files without issues.

This changes the representation of uploaded files from dictionaries to bona fide objects; see BackwardsIncompatibleChanges for details.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/request_response.txt

    r7510 r7814  
    8181 
    8282``FILES`` 
     83     
     84    .. admonition:: Changed in Django development version 
     85         
     86        In previous versions of Django, ``request.FILES`` contained 
     87        simple ``dict`` objects representing uploaded files. This is 
     88        no longer true -- files are represented by ``UploadedFile`` 
     89        objects as described below. 
     90         
     91        These ``UploadedFile`` objects will emulate the old-style ``dict`` 
     92        interface, but this is deprecated and will be removed in the next 
     93        release of Django. 
     94         
    8395    A dictionary-like object containing all uploaded files. Each key in 
    8496    ``FILES`` is the ``name`` from the ``<input type="file" name="" />``. Each 
    85     value in ``FILES`` is a standard Python dictionary with the following three 
    86     keys: 
    87  
    88         * ``filename`` -- The name of the uploaded file, as a Python string. 
    89         * ``content-type`` -- The content type of the uploaded file. 
    90         * ``content`` -- The raw content of the uploaded file. 
    91  
     97    value in ``FILES`` is an ``UploadedFile`` object containing the following 
     98    attributes: 
     99 
     100        * ``read(num_bytes=None)`` -- Read a number of bytes from the file. 
     101        * ``file_name`` -- The name of the uploaded file. 
     102        * ``file_size`` -- The size, in bytes, of the uploaded file. 
     103        * ``chunk()`` -- A generator that yields sequential chunks of data. 
     104 
     105    See `File Uploads`_ for more information.  
     106     
    92107    Note that ``FILES`` will only contain data if the request method was POST 
    93108    and the ``<form>`` that posted to the request had 
    94109    ``enctype="multipart/form-data"``. Otherwise, ``FILES`` will be a blank 
    95110    dictionary-like object. 
     111     
     112    .. _File Uploads: ../upload_handling/ 
    96113 
    97114``META``