Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Download File Url #2

Closed
bhavens17 opened this issue Jun 4, 2022 · 5 comments
Closed

No Download File Url #2

bhavens17 opened this issue Jun 4, 2022 · 5 comments
Labels
area:Picker documentation Improvements or additions to documentation

Comments

@bhavens17
Copy link

I've implemented the Javascript client logic into my app and can successfully show the file picker to a user and allow them to select file(s) from their OneDrive, however when I receive the file information in the message handler after selecting the files there doesn't appear to be a 'Download Url' value. I was expecting to receive a '@microsoft.graph.downloadUrl' (or similar) value. The values that I'm receiving instead are:

@sharePoint.embedUrl: "XXX"
@sharePoint.endpoint: "XXX"
@sharePoint.listUrl: "XXX"
folder: "XXX"
id: "XXX"
name: "XXX"
parentReference: {...}
size: XXX
webDavUrl: "XXX"
webUrl: "XXX"

Is there a certain param value that's required in order to get a download URL for the selected files? Or some other way to retrieve this information?

My current params are:

const params = {
        sdk: "8.0",
        entry: {
            oneDrive: {
                files: {},
            }
        },
        authentication: {},
        selection: {
            mode: 'multiple'
        },
        messaging: {
            origin: "https://localhost",
            channelId: "27"
        },
        typesAndSources: {
            mode: "files",
            pivots: {
                oneDrive: true,
                recent: false,
                sharedLibraries: true
            },
        },
    };
@patrick-rodgers
Copy link
Collaborator

I don't believe the download url is included, you can see this samples where we use the webDavUrl value to run the download. Alternatively, you can make a request to the graph drive item and get additional details that way (though I recognize that is an extra request).

@patrick-rodgers patrick-rodgers added the question Further information is requested label Jun 6, 2022
@bhavens17
Copy link
Author

I did try to go the route of using the access token used during the file picker process as a bearer auth token w/ the webDavUrl to request the selected files, but was getting an unauthorized response for that. Was just hoping to avoid having to run a second process to actually download the file.

@patrick-rodgers patrick-rodgers added enhancement New feature or request and removed question Further information is requested labels Jun 7, 2022
@AnkitBajpaii
Copy link
Contributor

I faced the exact same issue and as a work around, here's what i did:
After I selected the file(s) from file picker, I extracted the selected file Id's and then made an api call to microsoft graph end point (/me/drive) for each file id to get '@microsoft.graph.downloadUrl' for each file .
@patrick-rodgers Ideally this should be included in pick command. The file picker should give this pre-authenticated download url

@sriramsf3603
Copy link

sriramsf3603 commented Feb 6, 2023

@microsoft.graph.downloadUrl from the selected files is valid only for an hour. It is mentioned in documentation.
Documentation link: Link

image

@patrick-rodgers patrick-rodgers added documentation Improvements or additions to documentation and removed enhancement New feature or request labels Feb 9, 2023
@patrick-rodgers
Copy link
Collaborator

Going to close this as the returned object contains enough information to construct a valid Graph URL to get the file contents without the presence of the @microsoft.graph.downloadUrl field.

Recently updated docs describe this. To get the content you can add /content.

GET @sharePoint.endpoint + /drives/ + parentReference.driveId + /items/ + id + /content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Picker documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants