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.
The post Direct streaming of SharePoint Driveitem content in Microsoft Graph now available appeared first on Microsoft 365 Developer Blog.