def parse(self, stream, media_type=None, parser_context=None):
    "\n        Treats the incoming bytestream as a raw file upload and returns\n        a `DataAndFiles` object.\n\n        `.data` will be None (we expect request body to be a file content).\n        `.files` will be a `QueryDict` containing one 'file' element.\n        "
    parser_context = (parser_context or {})
    request = parser_context['request']
    encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)
    meta = request.META
    upload_handlers = request.upload_handlers
    filename = self.get_filename(stream, media_type, parser_context)
    content_type = meta.get('HTTP_CONTENT_TYPE', meta.get('CONTENT_TYPE', ''))
    try:
        content_length = int(meta.get('HTTP_CONTENT_LENGTH', meta.get('CONTENT_LENGTH', 0)))
    except (ValueError, TypeError):
        content_length = None
    for handler in upload_handlers:
        result = handler.handle_raw_input(stream, meta, content_length, None, encoding)
        if (result is not None):
            return DataAndFiles({}, {'file': result[1]})
    possible_sizes = [x.chunk_size for x in upload_handlers if x.chunk_size]
    chunk_size = min(([((2 ** 31) - 4)] + possible_sizes))
    chunks = ChunkIter(stream, chunk_size)
    counters = ([0] * len(upload_handlers))
    for (index, handler) in enumerate(upload_handlers):
        try:
            handler.new_file(None, filename, content_type, content_length, encoding)
        except StopFutureHandlers:
            upload_handlers = upload_handlers[:(index + 1)]
            break
    for chunk in chunks:
        for (index, handler) in enumerate(upload_handlers):
            '\n                Trimming HttpResponse encapsulation from parsed file stream\n                '
            chunk_length = len(chunk)
            start = (chunk.find(bytes('\n\r\n', 'utf-8')) + 3)
            end = chunk.rfind(bytes('\r\n', 'utf-8'))
            end = (chunk[:end].rfind(bytes('\r\n', 'utf-8')) + 2)
            chunk = handler.receive_data_chunk(chunk[start:end], counters[index])
            counters[index] += chunk_length
            if (chunk is None):
                break
    for (index, handler) in enumerate(upload_handlers):
        file_obj = handler.file_complete(counters[index])
        if (file_obj is not None):
            return DataAndFiles({}, {'file': file_obj})
    raise ParseError(self.errors['unhandled'])
Treats the incoming bytestream as a raw file upload and returns
a `DataAndFiles` object.

`.data` will be None (we expect request body to be a file content).
`.files` will be a `QueryDict` containing one 'file' element.
def parse(self, stream, media_type=None, parser_context=None):
    "\n        Treats the incoming bytestream as a raw file upload and returns\n        a `DataAndFiles` object.\n\n        `.data` will be None (we expect request body to be a file content).\n        `.files` will be a `QueryDict` containing one 'file' element.\n        "
    parser_context = (parser_context or {})
    request = parser_context['request']
    encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)
    meta = request.META
    upload_handlers = request.upload_handlers
    filename = self.get_filename(stream, media_type, parser_context)
    content_type = meta.get('HTTP_CONTENT_TYPE', meta.get('CONTENT_TYPE', ))
    try:
        content_length = int(meta.get('HTTP_CONTENT_LENGTH', meta.get('CONTENT_LENGTH', 0)))
    except (ValueError, TypeError):
        content_length = None
    for handler in upload_handlers:
        result = handler.handle_raw_input(stream, meta, content_length, None, encoding)
        if (result is not None):
            return DataAndFiles({}, {'file': result[1]})
    possible_sizes = [x.chunk_size for x in upload_handlers if x.chunk_size]
    chunk_size = min(([((2 ** 31) - 4)] + possible_sizes))
    chunks = ChunkIter(stream, chunk_size)
    counters = ([0] * len(upload_handlers))
    for (index, handler) in enumerate(upload_handlers):
        try:
            handler.new_file(None, filename, content_type, content_length, encoding)
        except StopFutureHandlers:
            upload_handlers = upload_handlers[:(index + 1)]
            break
    for chunk in chunks:
        for (index, handler) in enumerate(upload_handlers):
            '\n                Trimming HttpResponse encapsulation from parsed file stream\n                '
            chunk_length = len(chunk)
            start = (chunk.find(bytes('\n\r\n', 'utf-8')) + 3)
            end = chunk.rfind(bytes('\r\n', 'utf-8'))
            end = (chunk[:end].rfind(bytes('\r\n', 'utf-8')) + 2)
            chunk = handler.receive_data_chunk(chunk[start:end], counters[index])
            counters[index] += chunk_length
            if (chunk is None):
                break
    for (index, handler) in enumerate(upload_handlers):
        file_obj = handler.file_complete(counters[index])
        if (file_obj is not None):
            return DataAndFiles({}, {'file': file_obj})
    raise ParseError(self.errors['unhandled'])