0

I have a video file named simpleVideo2 (360p).mp4 in folder Video Assets(It's document library), and I want to know if it's possible to fetch file metadata through the REST API to get the video's duration?

I tried searching for relevant information in PnP.js, but I couldn't find any results regarding CAMLQuery. As a result, I couldn't understand the examples provided in PnP.js

If possible, I would also like to retrieve the thumbnail of the video.

Video duration property in spfx-list

2
  • Do you want to get video's duration dynamically? or do you have custom column in document library for video duration where you set video duration manually? Commented Aug 14, 2023 at 10:24
  • I have a document library where I store videos, and I want to display their durations on my page (a list). I noticed that the file summary information in SPFx list has this property, so I'm wondering if it's possible to retrieve it through REST API or any other means.
    – LanMegumi
    Commented Aug 15, 2023 at 1:35

2 Answers 2

0

The file information panel in your picture uses the SharePoint REST api v2.1, which returns unformatted metadata on video files like in the following Postman screenshot.

enter image description here

Unfortunately the documentation on using the v2.1 REST api is pretty minimal, however the endpoints are basically the same as for the Microsoft Graph api and the Drive/DriveItem endpoints.

See https://learn.microsoft.com/en-us/sharepoint/dev/apis/sharepoint-rest-graph

2
  • Thanks for your answer. I haven't used the Graph API before, and there's so much to learn about SPFx. Besides the Microsoft documentation and PnP community, do you have any other recommended learning websites? Specifically, related to the knowledge that might be involved in my question.
    – LanMegumi
    Commented Aug 17, 2023 at 4:28
  • Nothing specific for learning, but there is a lot to know. Web searching helps a lot, as does being proficient with tools like the browser dev tools, Postman, Fiddler etc, as sometimes you need to figure things out for yourself.
    – Paul Lucas
    Commented Aug 18, 2023 at 1:20
1

if you are using PnP.js try this:

// file is an IFile and supports all the file operations
const file = await sp.web.getFileByServerRelativePath(url);
const props = await file.listItemAllFields
          .select("*,listItemAllFields")
          .expand("listItemAllFields")
          .get();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.