pnp / pnpcore

The PnP Core SDK is a modern .NET SDK designed to work for Microsoft 365. It provides a unified object model for working with SharePoint Online and Teams which is agnostic to the underlying API's being called
https://aka.ms/pnp/coresdk/docs
MIT License
288 stars 188 forks source link

Ability to Get File Version Preview #1408

Closed DanTm99 closed 4 months ago

DanTm99 commented 4 months ago

Category

Describe the feature

Get a file preview url for a given file version, to be used in an iframe. Similar to GetUrl from the IFilePreview returned by IFile.GetPreview() and IFile.GetPreviewAsync().

Describe the solution you'd like

Add IFileVersion.GetPreview() and IFileVersion.GetPreviewAsync() that return IFilePreview and Task<IFilePreview> respectively.

Additional context

jansenbe commented 4 months ago

@DanTm99 : PnP Core SDK is a wrapper on top of various Microsoft SharePoint/Teams APIs. In case of preview we use the Graph preview API (https://learn.microsoft.com/en-us/graph/api/driveitem-preview?view=graph-rest-1.0), however this API is not available for a file version (https://learn.microsoft.com/en-us/graph/api/resources/driveitemversion?view=graph-rest-1.0). The same applies to the REST/CSOM APIs (https://s-kainet.github.io/sp-rest-explorer/#/entity/SP.FileVersion).

Given there's no API that can offer this feature we can't implement here. The only possible way I see if you restore an older version as current version, grab the preview and store that somewhere and then set the previous version back as current. This behavior however is not something we should include in the SDK as it temporarily overwrites data just to get a preview.

Hope you understand, but I have to close this one.