Direct streaming of SharePoint Driveitem content in Microsoft Graph now available

Sanjukta Sen

You can now directly download content of a file (of a Driveitem) in a SharePoint Online site through a single call. 

Previously, while downloading file content via any endpoint mentioned here, you used to get ‘302 Found’ response redirecting to a pre-authenticated download URL (which is the same URL available through the ‘microsoft.graph.downloadurl’ property on the Driveitem) which you had to call again to start the download process. This resulted in redundant calls increasing the network overhead. 

A new Microsoft Graph endpoint is introduced in BETA to enable you download content of file* through a single call, e.g., when you hit ‘GET /drives/{drive-id}/items/{item-id}/contentStream’, it will start downloading the content from the stated drive-id directly.  

*Please note, only driveitem objects with the ‘file’ property can be downloaded. 

What are the benefits? 

The new endpoint improves network performance by eliminating redundant calls and enhances security by enabling direct streaming. 

How do I use it? 

Call any of the following endpoints to get started: 

Please use ‘BETA’ version. 

GET /drives/{drive-id}/items/{item-id}/contentStream 

GET /groups/{group-id}/drive/items/{item-id}/contentStream 

GET /me/drive/root:/{item-path}:/contentStream 

GET /me/drive/items/{item-id}/contentStream 

GET /shares/{shareIdOrEncodedSharingUrl}/driveItem/contentStream 

GET /sites/{siteId}/drive/items/{item-id}/contentStream 

GET /users/{userId}/drive/items/{item-id}/contentStream 

For more details, please refer to this document. 

5 comments

Leave a comment

  • Jørgen Solberg 0

    Great work! Will this also work with etags ?

    • Arjun AgarwalMicrosoft employee 1

      Thank you! Yes, this is expected to work with etags.

      • Jørgen Solberg 0

        Even better! 🙂 Any expectation on when it will hit v1?

  • Paul Jones 0

    With the pre-authenticated downloadURL we effectively got a snapshot of the item at that point in time and could download it in chunks using the range headers etc… With the stream endpoint, if the file is modified mid stream how is that handled? Will it abort or are we effectively streaming a snapshot tied to the connection session etc..?

    • Sanjukta SenMicrosoft employee 0

      The enhanced endpoint enables you download directly without being redirected through pre-authenticated url but the download process remains same. So, you can still download partial content using range headers and it will enable download of realtime content, which means, if any byte is modified and synced before download, you will get updated content.

Feedback usabilla icon