pnp/PnP

Decode SharePoint Online Sharing links

semopz opened this issue · 0 comments

Category

[ ] Bug
[x] Enhancement

Environment

[x] Office 365 / SharePoint Online
[ ] SharePoint 2016
[ ] SharePoint 2013

If SharePoint on-premises, what's exact CU version:

Expected or Desired Behavior

This is more of a question than a suggestion. I'm looking for a CSOM or a REST API that would allows me to decode any kind of a SharePoint sharing link. For example, if you got to a modern UI library to get the link of document, you may be presented with something like this:
https://contoso.sharepoint.com/:i:/r/sites/someweb/SiteAssets/cats.jpg?csf=1&e=L9eqe2
This may not look too bad but sharing/anon links are a lot more cryptic.

As a developer, I should be able to decode any links generated by SharePoint (and therefore provided to my app/service/function via a user) in order to get the file's actual path and content.

Observed Behavior

If I supply a link that I've obtained from the SP Online Modern UI interface and feed it as a URL param to Get-PnPFile, I will not get a valid SPFile object. I'm using a PowerShell cmdlet as an example here but other PnP libraries or _api calls will result in a failure.

Are there any APIs that would allow me to decode a valid SharePoint links that users may supply to my solution?

Steps to Reproduce

  1. Get a link to a file from a SharePoint Online Modern UI library
  2. Try to obtain content or field information using SharePoint APIs with the link obtained in step 1