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

Download file by Link #1054

Closed
1 task done
No1e opened this issue Dec 10, 2022 · 5 comments
Closed
1 task done

Download file by Link #1054

No1e opened this issue Dec 10, 2022 · 5 comments
Assignees

Comments

@No1e
Copy link

No1e commented Dec 10, 2022

Category

  • Feature request

Describe the feature

Download file from SharePoint by using Link created in SharePoint.

Describe the solution you'd like

I was not able to find API for this, so my apologies if there is already way to achieve this.
It would be great if there would be a possibility to download file by using Link created in SharePoint (selecting given file in SharePoint and Copy Link).

Additional context

jansenbe added a commit that referenced this issue Dec 12, 2022
… (any fully qualified link to a file, including sharing links) using the `GetFileByLink` methods on `IWeb` #1054
@jansenbe
Copy link
Contributor

@No1e : I've just added extra method that allow you to get a file by either id or link. In your case the link option is what you need, just pass in a fully qualified link to the file (e.g. a sharing link) and you'll get back an IFile (see https://pnp.github.io/pnpcore/using-the-sdk/files-intro.html#get-a-file-using-a-link for the docs). Once you have the IFile instance you can download it's content as described here: https://pnp.github.io/pnpcore/using-the-sdk/files-intro.html#downloading-files.

This new functionality will be available with our next nightly release (version 1.8.36 or higher). I'll close this issue now, but don't hesitate to re-open if you can't get this to work.

Thanks for using PnP Core SDK and providing feedback.

@jansenbe jansenbe self-assigned this Dec 12, 2022
@No1e
Copy link
Author

No1e commented Dec 12, 2022

@jansenbe Awesome!

Thank you very much!

@No1e
Copy link
Author

No1e commented Dec 13, 2022

@jansenbe I just tested new feature, it works. Thank you very much.
I had to configure two API permissions (scopes) in Azure Identity:

  • Microsoft Graph: Files.Read.All
  • SharePoint: Sites.Read.All

This works, but its not optimal setup from the security perspective. What's relative new is the SharePoint: Sites.Selected.
Do you know how can I configure for which SharePoint sites the client has Read permission (scope)?

Best regards,
Novak

@jansenbe
Copy link
Contributor

@No1e : PnP Core SDK requires both Graph and SharePoint permission scopes as it uses both APIs under the cover. If you only want to rely on Graph you can use the Graph SDKs.

Sites.Selected is a model that allows an app (using sites.fullcontrol.all application permission or being ran as global admin) to grant another app access to one or more site collections using either read or write permissions. There's no UI for this, so you'll need to resort to APIs to configure this (see https://learn.microsoft.com/en-us/graph/api/resources/permission). The API docs however don't give you a good overview, Paolo's videos are good resources + there are also some good blog posts (https://www.google.com/search?q=sites.selected&oq=sites.selected&aqs=edge..69i57j0i512l7j69i64.2329j0j1&sourceid=chrome&ie=UTF-8).

Here's an example of the API call to grant an app permissions to a given site collection:
image

@No1e
Copy link
Author

No1e commented Dec 13, 2022

@jansenbe
Yes, I realized from your source code, that you are using both APIs.

Thank you very much for the answer and provided links to related documentation and blogs, where I can learn more.

Best regards,
Novak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants