简体   繁体   English

如何使用 Python 将.aspx 页面正确上传到 SharePoint

[英]How to properly upload .aspx page to SharePoint using Python

I'm able to upload an Aspx page to my SharePoint project with the help of Python.在 Python 的帮助下,我可以将 Aspx 页面上传到我的 SharePoint 项目。 The project has an "Edit" button for every Aspx page created in SharePoint which helps in editing the content of the page.该项目对于在 SharePoint 中创建的每个 Aspx 页面都有一个“编辑”按钮,这有助于编辑页面的内容。

But the uploaded page from Python does not have any action for the "Edit" button.但是从 Python 上传的页面对“编辑”按钮没有任何操作。 I want to know why is this happening.我想知道为什么会这样。 I'm new to Python and SharePoint automation please help me out.我是 Python 和 SharePoint 自动化的新手,请帮帮我。

Code to upload Aspx page:上传 Aspx 页面的代码:

path = "local path to my .aspx"

with open(path, 'rb') as content_file:
  file_content = content_file.read()
target_folder = ctx.web.get_folder_by_server_relative_url(My_SharePoint_Folder_Path)
name = os.path.basename(path)
target_file = target_folder.upload_file(name, file_content).execute_query()
print("File has been uploaded to url: {0}".format(target_file.serverRelativeUrl))

This is the button that I'm talking about: Edit Button这是我正在谈论的按钮:编辑按钮

Am I doing something wrong or do I have to change settings.我做错了什么还是我必须更改设置。 Please help!!请帮忙!!

Problem related to content types of files you try to upload, files with ContentType of Site Page can edit by SharePoint与您尝试上传的文件的内容类型有关的问题,具有站点页面的 ContentType 的文件可以由 SharePoint 编辑

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM