To download a large file using Microsoft Graph, you can use the CreateUploadSession
API to create an upload session. This will allow you to upload the file in chunks, which will help to avoid memory exceptions. The API call you need to use is POST /drives/{driveId}/items/{itemId}/createUploadSession
. For more information about this API, see the Microsoft Graph documentation.
Graph DriveItem Content Stream?
I want to be able to download a large file using Graph. To do so, I need to "chunk" the file, because it's too large to fit into the memory available. Unfortunately the only call I know reads the entire file into memory immediately. Is there a way to avoid this? What call should I be using?
The call I'm using is:
graphClient.Drives[driveId].Items[itemId].Content.Request().GetAsync()
I want to use "CopyToAsync" with a buffer size to send this stream to my response stream, but it blows up on a memory exception before I can.
Any help would be much appreciated!
P.S. Why are there no tags for "Graph.Drives"?!?
1 answer
Sort by: Most helpful
-
Diya Ahuja 5 Reputation points
2023-06-30T18:09:28.4+00:00