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]
[ValidateAntiForgeryToken]
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?