如何通过Python使用CMis更新alfresco中的现有文件
下面是我用来上传文件的方法
def alfresco_post_file(url, user, pwd, root_folder, post_folder, post_file, file_name, logger):
client = CmisClient(url, user, pwd)
repo = client.defaultRepository
try:
folder = repo.getObjectByPath('/'+root_folder)
if post_folder:
folder = repo.getObjectByPath('/'+post_folder)
contents = open(post_file, 'r')
file = folder.createDocument(file_name, contentFile = contents)
except Exception as e:
sys.exc_clear()
if type(e).__name__ == 'ObjectNotFoundException':
folder = repo.getObjectByPath('/'+root_folder)
createfolder = folder.createFolder(post_folder.replace(root_folder+'/',''))
folder = repo.getObjectByPath('/'+post_folder)
contents = open(post_file, 'r')
file = folder.createDocument(file_name, contentFile = contents)
#elif type(e).__name__ == 'UpdateConflictException':
#folder = repo.getObjectByPath('/'+post_folder)
#contents = open(post_file, 'r')
#file = folder.updateDocument(file_name, contentFile = contents)
else:
print("(alfresco_post_file) Execution failed:", e)
logger.info('(alfresco_post_file) Execution failed:' + str(e));
源代码通常是很好的示例源代码。在本例中,我从中的一个测试中获取了几行代码cmislibtest.py文件地址:
相关问题 更多 >
编程相关推荐