You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Office365包实现SharePoint已上传文件的自动签入?

解决SharePoint文件上传后自动签入的问题

Office365 Python库支持自动签入操作,你可以在文件上传完成后,调用文件对象的check_in()方法实现自动签入。

修改你的代码如下,添加签入步骤:

def csv_to_sp(spfile_path,output):
    ctx = Extract.connect()
    target_folder =  ctx.web.get_folder_by_server_relative_url(spfile_path)
    with open(output,'rb') as content_file:
        file_content = content_file.read()

    # 上传文件并获取文件对象
    uploaded_file = target_folder.upload_file(output,file_content)
    uploaded_file.execute_query()
    
    # 执行自动签入,可添加签入注释(可选)
    uploaded_file.check_in(comment="自动签入上传文件")
    uploaded_file.execute_query()
    
    response = 'Uploaded and checked in to sharepoint!'
    return response

说明

  • 上传文件后,先通过upload_file()获取到文件对象,再调用check_in()方法,最后执行execute_query()完成签入操作。
  • 如果你的SharePoint文档库开启了强制签出功能,这个方法可以直接替代手动签入操作。

内容的提问来源于stack exchange,提问作者user11956646

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 13:40:58