'Detects the uploaded file name. First searches a \'filename\' url kwarg.
Then tries to parse Content-Disposition header.'

def get_filename(self, stream, media_type, parser_context):

    try:
        return parser_context[u'kwargs'][u'filename']
    except KeyError:
        pass
    try:
        meta = parser_context[u'request'].META
        disposition = parse_header(meta[u'HTTP_CONTENT_DISPOSITION'].encode(u'utf-8'))
        filename_parm = disposition[1]
        if (u'filename*' in filename_parm):
            return self.get_encoded_filename(filename_parm)
        return force_text(filename_parm[u'filename'])
    except (AttributeError, KeyError, ValueError):
        pass
