Need Help - Developing App and a Bug with Browsing for Files

☑️ Solved

Hey everyone, don't know where to turn so I did some searching and found this community so I'm giving it a shot.

I'm a Cloud Practice Manager for an MS Consulting Firm and we are developing an App for a client to be sold in the MS store. I have a Microsoft PM for the process but I can't execute it until we solve this one bug and we could use a point in the right direction because Google, Bing, and Microsoft's own documentation has nothing on the subject.

We are building an app that we have to have functionality to Browse for a File in SharePoint/OneDrive.

This is already native in Teams so I know the functionality exists.

We are using this Plug-In which is a Microsoft Developed Picker: https://learn.microsoft.com/en-us/onedrive/developer/controls/file-pickers/?view=odsp-graph-online

We have successfully gotten it to work if you use the Teams Client in a Web Browser but the desktop FAT client it doesn't work period.

Has anyone on here successfully done this or can point me to a link that fixes this bug OR another plugin that works properly. Based on the comments on that Picker, this is a known bug that hasn't been fixed by the Dev yet.

Thanks in advance!

I will buy some beer for anyone that can solve this ;)

Posted Jun 6, 2023, 4:05 PM UTC

14
Ryanisadeveloper•

Try the ms graph toolkit component

https://learn.microsoft.com/en-us/graph/toolkit/components/file

It's likely the plugin you are using needs the token from the session storage which may not be provided in the same way with the desktop client (guessing though, not had this problem).

Graph toolkit definitely works in all clients. I use it in my store apps.

2
datracemanOP•

Thanks we are trying it now. Will report back.

Appreciate the answer.

1
AutoModeratorMOD•

Hey! If you were encountering an issue and it is now resolved, please change the post flair to Solved! If you are still looking for more help, then leave it as is. (This message is an auto response to terms like thank you, so I apologize if I spam you)

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1
datracemanOP•

To follow up, the plug in has a bug in it and the Microsoft Developer hasn't bothered to fix it in the last 6 months.

So I went down a Rabbit hole and found this JS with some modifications to include PDFs, we were in business:

document.getElementById('browseButton').addEventListener('click', function() {

// Call the Microsoft Graph API to retrieve SharePoint and OneDrive files microsoftTeams.files.selectFiles({

accept: ['.docx', '.xlsx', '.pptx'],

multiple: false,

successCallback: function(response) {

var selectedFile = response[0]; document.getElementById('selectedFileName').textContent = 'Selected File: ' + selectedFile.name; }, failureCallback: function(error) { console.error(error); } }); });

1