MicrosoftDocs / msteams-docs

Source for the Microsoft Teams developer platform documentation.
https://aka.ms/teamsdev
Creative Commons Attribution 4.0 International
281 stars 502 forks source link

Download files using Teams SDK #10334

Open Wajeed-msft opened 7 months ago

Wajeed-msft commented 7 months ago

Copied bug from: https://github.com/OfficeDev/TeamsFx/issues/10813

Details from original post: Is your feature request related to a problem? Please describe. File downloads are hard in Teams apps because of the restrictions in embedded web browsers/Electron apps. There are numerous security and cross browser quirks to consider.

Describe the solution you'd like I wish that there was methods in the SDK for starting a user friendly file download experience in the Teams apps. Some possible parameters are:

Additional context Saving blobs using FileSaver.js used to work in old Teams app, but no longer works correctly in new Teams. The first file will be downloaded, but subsequent downloads are blocked.

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

microsoft-github-policy-service[bot] commented 7 months ago

Hi Wajeed-msft! Thank you for bringing this issue to our attention. We will investigate and if we require further information we will reach out in one business day. Please use this link to escalate if you don't get replies.

Best regards, Teams Platform

Prasad-MSFT commented 7 months ago

Hi @gabbsmo - Could you please provide the repro steps or minimal code snippet/reference doc which you followed to repro the behaviour of saving blobs failure using FileSaver.js?

gabbsmo commented 7 months ago

A full repro with authentication to SharePoint is going to take some time to develop. I added a code snippet below that is using $http from Angular.JS (which abstracts XMLHttpRequest) to download a file from SharePoint Online. Please let me know if you need more information.

function download(webUrl, fileServerRelativeUrl) {
    var downloadUrl = webUrl + "/_api/web/getfilebyserverrelativeurl('" + fileServerRelativeUrl + "')/$value";

    var config = {
        responseType: 'blob'
    };

    return $http.get(downloadUrl, config)
        .then(function (response) {
            // saveAs defined in /node_modules/file-saver/dist/FileSaver.js
            saveAs(response.data, 'download.docx');
        });
}
Prasad-MSFT commented 7 months ago

@gabbsmo - Could you please share a repro video along with repro steps, so that we can raise a bug for this?

gabbsmo commented 7 months ago

@Prasad-MSFT You can find the videos here: https://ways-my.sharepoint.com/:f:/g/personal/gabriel_smoljar_ways_se/Ej9VL3cYwNdCjH185wmj-JkBDJ5qt-5ln5j55E5Qtpy8hg?e=oB5rwi

Prasad-MSFT commented 7 months ago

@gabbsmo - We have raised a bug for this issue. We will inform you once we get any update from engineering team.

Thanks!

takeungrae commented 7 months ago

I too am not able to get it to work due to the same error. Waiting for a reply from ms. new Teams seems to have a lot of bugs.