如何构建/获取共享点文档的 Office Web App URL

问题描述:

我正在尝试为我的 sharepoint 文档获取正确的重定向 URL,然后我可以使用它在 iOS 的 WebView 中打开文档.目前,我正在提供文档在 WebView 中呈现为 PDF(图像/只读)的文档的绝对 URL.而我想重定向到办公室 webapp.现在我的问题是我不知道 office web 应用程序的 URL 是否是我可以构建的东西,比如附加/_layouts/15/WopiFrame.aspx?sourcedoc= 或者是基于安装的 URL 自定义,我们需要调用一些 Sharepoint API会让我们知道 Wopi 服务的基本 URL 是什么.

I am trying to get the right redirection URL for my sharepoint documents which then I can use to open documents in WebView of iOS. Currently I am giving the absolute URL for the document where the doc is rendered inside WebView as PDF(Image/Readonly). Whereas I want to redirect to office webapp. Now my issue is I dont know if the URL for office web app is something which I can construct like appending /_layouts/15/WopiFrame.aspx?sourcedoc= or is the URL custom based on installations and we need to call some Sharepoint API which will let us know what is the base URL for Wopi service.

目前我正在传递 URL 之类的 - https://.sharepoint.com/Shared%20Documents/demo/demo.docx而我想传递这样的 URL - https://.sharepoint.com/_layouts/15/WopiFrame.aspx?sourcedoc=/Shared%20Documents/demo/demo.docx

Currently I am passing URL like - https://.sharepoint.com/Shared%20Documents/demo/demo.docx Whereas I want to pass URL like - https://.sharepoint.com/_layouts/15/WopiFrame.aspx?sourcedoc=/Shared%20Documents/demo/demo.docx

期待帮助.提前致谢,维什韦什

Looking forward for help. Thanks in advance, Vishwesh

File f = clientContext.Web.GetFileByServerRelativeUrl("/sites/  /Shared%20Documents/Title.docx");
clientContext.Load(f);
clientContext.ExecuteQuery();

ClientResult<String> result = f.ListItemAllFields.GetWOPIFrameUrl(SPWOPIFrameAction.Edit);

clientContext.Load(f.ListItemAllFields);
clientContext.ExecuteQuery();

result.Value 包含一个 URL,如下所示:http://sharep.xxx:8080/sites/zxxx/_layouts/15/WopiFrame.aspx?sourcedoc=%2Fsites%2Fzxxx%2FShared%20Documents%2FTitle%2Edocx&action=edit

result.Value contains a URL, something like this: http://sharep.xxx:8080/sites/zxxx/_layouts/15/WopiFrame.aspx?sourcedoc=%2Fsites%2Fzxxx%2FShared%20Documents%2FTitle%2Edocx&action=edit

如果您根本不想点击共享点,也可以从上述页面中提取提取的 Office Web Apps URL.

Also you can extract the extract Office Web Apps URL from the above page, if you don't want to hit the sharepoint at all.