OneDrive云提供了一种获得嵌入iFrame标记的功能,其中包含一个可公开访问的iFrame。我正试图用Python SDK实现同样的目标
文档页面上显示了各种特性,比如上传、下载、重命名文件等等。我在这里试图实现的是创建一个嵌入式iFrame并得到响应。有点像这。
SDK的一个类中有一个名为create_link的函数。此函数位于其他函数(如upload
)存在的同一个类中。onedrivesdk/request/item_request_builder.pyitem_builder_request.py
还有一个可以使用的type
参数。我相信,embed
将是我们将通过的论点。但是,当我执行client.item(drive='me', id='fileid').create_link('embed')
时,它不会给出与在这页面上使用Graph时显示的结果相同的结果。我该怎么办?
我的目的基本上是获得一个公共URL的excel表,我通过上传。python代码。此URL不应要求登录。
def create_link(self, type):
"""Executes the createLink method
Args:
type (str):
The type to use in the method request
Returns:
:class:`ItemCreateLinkRequestBuilder<onedrivesdk.request.item_create_link.ItemCreateLinkRequestBuilder>`:
A ItemCreateLinkRequestBuilder for the method
"""
return ItemCreateLinkRequestBuilder(self.append_to_request_url("action.createLink"), self._client, type)
我现在拥有的是上传文件后的item对象。
发布于 2019-01-24 13:04:28
在您的示例中,缺少post
方法,它基本上是向服务器提交一个POST请求。
因此,创建嵌入链接的查询
POST /me/drive/items/{item-id}/createLink
Content-Type: application/json
{
"type": "embed"
}
可以通过这样的Python OneDrive SDK
执行:
result = client.item(drive='me', id=item_id).create_link("embed").post()
print(result.link.web_url)
其中,item_id
是驱动器项的id。
https://stackoverflow.com/questions/54327805
复制相似问题