admin管理员组文章数量:1305103
We use onedrive/sharepoint for our document storage and there is a ability to open files in the desktop app. You use an extension on the url which is built into most browsers for your javascript so I prebuild the url with the correct extension below. It seems that there might be one for adobe as onedrive has this functionality but I think I am doing this wrong as it errors out in my javascript when it goes to open the new window via the built url:
[HttpPost]
[ValidateAntiFeryToken]
public async Task<ActionResult> SharedLinkData([FromForm] string FilePath)
{
var fullPath = Path.Combine(fileDirectory, FilePath);
var SharedLinkResponse = await oneDrive.DriveItemLinksAsync(SharedDriveID, fullPath, "path", "users", "edit");
var driveItem = await oneDrive.DriveItemInfoAsync(SharedDriveID, fullPath, "path");
var wordExtensions = new List<String>{".doc", ".docx", ".dotx", ".odt"};
var excelExtensions = new List<String>{".xlsx", ".xlsm", ".xls", ".xlsb", ".xltx", ".xlt"};
var powerPointExtensions = new List<String>{".ppt", ".pptx", ".pptm", ".potx", ".pot", ".potm", ".ppam", ".ppa", ".thmx"};
var adobeExtensions = new List<String>{".pdf"};
var currentFileExtension = Path.GetExtension(driveItem.WebDavUrl).ToLower();
if(wordExtensions.Contains(currentFileExtension))
{
return Ok("ms-word:ofe|u|"+driveItem.WebDavUrl);
} else if (excelExtensions.Contains(currentFileExtension))
{
return Ok("ms-excel:ofe|u|"+driveItem.WebDavUrl);
} else if (powerPointExtensions.Contains(currentFileExtension))
{
return Ok("ms-powerpoint:ofe|u|"+driveItem.WebDavUrl);
} else if (adobeExtensions.Contains(currentFileExtension))
{
return Ok("odopen://"+driveItem.WebDavUrl);
}
return Ok(SharedLinkResponse.Link.WebUrl);
}
It is unclear if odopen:// is the correct start. If you try it in onedrive and monitor the network requests I see
odopen://openFile/?fileId=blasdflasdflas&siteId=asdfsadfsdfsdf&listId=%7Bd02b7574%2D2dfasdfasdfa&userEmail=john%2EDoe%40test%2Esomething%2Ecome&userId=dfsdfsf5&webUrl=dfasdfasfdsadfsadfasdfsadf
So maybe I need to compile all of this for it to work? Or even better maybe I can get ms graph to generate this somehow for me to make my life easier?
本文标签: javascriptHow to open a pdf file in desktop app from ms graph apiStack Overflow
版权声明:本文标题:javascript - How to open a pdf file in desktop app from ms graph api - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741792022a2397714.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论