class documentation

class MultiPartParser:

View In Hierarchy

A rfc2388 multipart/form-data parser.

MultiValueDict.parse() reads the input stream in chunk_size chunks and returns a tuple of (MultiValueDict(POST), MultiValueDict(FILES)).

Method __init__ Initialize the MultiPartParser object.
Method ​_close​_files Undocumented
Method handle​_file​_complete Handle all the signaling that takes place when a file is complete.
Method parse Parse the POST data and break it into a FILES MultiValueDict and a POST MultiValueDict.
Method sanitize​_file​_name Sanitize the filename of an upload.
Instance Variable ​_boundary Undocumented
Instance Variable ​_chunk​_size Undocumented
Instance Variable ​_content​_length Undocumented
Instance Variable ​_encoding Undocumented
Instance Variable ​_files Undocumented
Instance Variable ​_input​_data Undocumented
Instance Variable ​_meta Undocumented
Instance Variable ​_post Undocumented
Instance Variable ​_upload​_handlers Undocumented
def __init__(self, META, input_data, upload_handlers, encoding=None):
Initialize the MultiPartParser object.
Unknown Field: meta
The standard META dictionary in Django request objects.
Unknown Field: input_data
The raw post data, as a file-like object.
Unknown Field: upload_handlers
A list of UploadHandler instances that perform operations on the uploaded data.
Unknown Field: encoding
The encoding with which to treat the incoming data.
def _close_files(self):

Undocumented

def handle_file_complete(self, old_field_name, counters):
Handle all the signaling that takes place when a file is complete.
def parse(self):

Parse the POST data and break it into a FILES MultiValueDict and a POST MultiValueDict.

Return a tuple containing the POST and FILES dictionary, respectively.

def sanitize_file_name(self, file_name):

Sanitize the filename of an upload.

Remove all possible path separators, even though that might remove more than actually required by the target system. Filenames that could potentially cause problems (current/parent dir) are also discarded.

It should be noted that this function could still return a "filepath" like "C:some_file.txt" which is handled later on by the storage layer. So while this function does sanitize filenames to some extent, the resulting filename should still be considered as untrusted user input.

_boundary =

Undocumented

_chunk_size =

Undocumented

_content_length =

Undocumented

_encoding =

Undocumented

_files =

Undocumented

_input_data =

Undocumented

_meta =

Undocumented

_post =

Undocumented

_upload_handlers =

Undocumented