Open a file directly in Teams from a tab

妖精的绣舞 提交于 2021-01-25 07:00:17

问题


I have deployed a SharePoint webpart (SharePoint Framework) to Microsoft Teams. In this web part, I have a list of files that I want to open directly in Teams.

I have tried to get the link from the "Files" tab (https://teams.microsoft.com/l/file/7FFA7D9D-CBF1-4679-9C80-76446AE11ABD?tenantId=0f48c6f4-52a5-4553-b476-4ee2ee0aecca&fileType=docx&objectUrl=https%3A%2F%2Fxyz.sharepoint.com%2Fsites%2FAZRTZ%2FShared%20Documents%2FGeneral%2FArchitecture%2FTest.docx&baseUrl=https%3A%2F%2Fxyz.sharepoint.com%2Fsites%2FAZRTZ&serviceName=teams&threadId=19:0d1f6f397c51421189e791a9ab436a48@thread.skype&groupId=98edc5a8-02ac-4f58-8638-ea88ac6aaa4d) and put it in the href="" of the link. It does not work, it opens the file in the browser.

I also tried to put the direct link in the href (https://xyz.sharepoint.com/sites/AZRTZ/Shared Documents/General/Architecture/Test.docx). It downloads a copy of the file in the browser.

I want to open the file directly into Teams, the same way the files are opened if the user goes to the "Files" tab (eg. if the user opens a .doc file, Word Online in Teams must open, if the user opens an image, a previsualisation in Teams must be opened, ...)

Teams WebPart Tab

Teams Files Tab


回答1:


Succeed with a shorter version of the Deep Link syntax myself, in a message card from an incoming webhook connector, provided I used the OpenUri action syntax and not a plain markdown link:

https://teams.microsoft.com/l/file/?fileType=<extension>&objectUrl=<absoluteUrl>

this was linking to Sharepoint files.




回答2:


Using the Deep link I managed to open the file directly in Teams. I had to format the URL :

https://teams.microsoft.com/l/file/{file-id}
?tenantId={tenant-id}
&fileType={file-type (jpg, xlsx, docx, ...)}
&objectUrl={file-encoded-link (SharePoint link, aboslute URL)}


来源:https://stackoverflow.com/questions/56774236/open-a-file-directly-in-teams-from-a-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!