'Usage: upload [localpath] [remotepath] [ondup] - upload a file or directory (recursively)
localpath - local path, is the current directory \'.\' if not specified
remotepath - remote path at Baidu Yun (after app root directory at Baidu Yun)
ondup - what to do upon duplication (\'overwrite\' or \'newcopy\'), default: \'overwrite\''

def upload(self, localpath=u'', remotepath=u'', ondup=u'overwrite'):

    lpath = localpath.rstrip(u'\\/    ')
    lpathbase = os.path.basename(lpath)
    rpath = remotepath
    if (not lpath):
        lpath = os.path.abspath(u'.')
        self.pd(u"localpath    not    set,    set    it    to    current    directory    '{}'".format(localpath))
    if os.path.isfile(lpath):
        self.pd(u"Uploading    file    '{}'".format(lpath))
        if ((not rpath) or (rpath == u'/')):
            rpath = lpathbase
        if (rpath[(-1)] == u'/'):
            rpath = get_pcs_path((rpath + lpathbase))
        else:
            rpath = get_pcs_path(rpath)
            subresult = self.__get_file_info(rpath)
            if (subresult == const.ENoError):
                if self.__remote_json[u'isdir']:
                    rpath += (u'/' + lpathbase)
        self.pd(u"remote    path    is    '{}'".format(rpath))
        return self.__upload_file(lpath, rpath, ondup)
    elif os.path.isdir(lpath):
        self.pd(u"Uploading    directory    '{}'    recursively".format(lpath))
        rpath = get_pcs_path(rpath)
        return self.__upload_dir(lpath, rpath, ondup)
    else:
        perr(u"Error:    invalid    local    path    '{}'    for    uploading    specified.".format(localpath))
        return const.EParameter
