import base64


def decode_dcc_upload_contents(contents, encoding='utf-8'):
    """ decodes the content returned by a dcc.Upload component's callback
    :param contents: a string with a comma separating the content type and the
                     encoded content
    :param encoding: the encoding convention of the encoded content
    :return: decoded string
    """
    decoded = ""
    if contents is not None:
        content_type, content_string = contents.split(',')
        decoded = base64.b64decode(content_string)
        decoded = decoded.decode(encoding)
    return decoded