msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

Graph 5.x Download large file over 2GB have issue

Open tony-ssdut opened this issue 3 years ago • 3 comments

Describe the bug Graph 5.x Download large file over 2GB have issue When I trying to use graph DriveItem/Content to download large file content, I see the error below.

System.Net.Http.HttpRequestException: Cannot write more bytes to the buffer than the configured maximum buffer size: 2147483647. Stack Trace:  HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) HttpClientRequestAdapter.GetHttpResponseMessage(RequestInformation requestInfo, CancellationToken cancellationToken, Activity activityForAttributes, String claims) HttpClientRequestAdapter.SendPrimitiveAsync[ModelType](RequestInformation requestInfo, Dictionary2 errorMapping, CancellationToken cancellationToken) ContentRequestBuilder.GetAsync(Action1 requestConfiguration, CancellationToken cancellationToken) GraphDriveService.DownloadFileByIdAsync(String driveId, String driveItemId, RangeHeaderValue range, String eTag, CancellationToken cancellationToken) line 59 GraphDriveService.DownloadFileByIdAsync(String driveId, String driveItemId, CancellationToken cancellationToken) line 31 GraphDriveServiceTests.DownloadFileTest3() line 87 ThreadOperations.ExecuteWithAbortSafety(Action action)

To Reproduce Use Graph SDK to download drive file over 2GB

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

tony-ssdut avatar Jun 07 '23 09:06 tony-ssdut

@dev-tony-hu, I think the developers on this repo are going to say to use the 'download a large file from OneDrive' method.

I'm guessing you're receiving this error because the underlying HttpClient is sending the request with the default parameter of HttpCompletionOptions.ResponseContentRead meaning the entire response is buffered. I don't believe there is a way to override this so you'd need to drop back to using HttpClient directly.

See also:

  • https://stackoverflow.com/a/18720862/1259408
  • https://www.stevejgordon.co.uk/using-httpcompletionoption-responseheadersread-to-improve-httpclient-performance-dotnet

NickDarvey avatar Jun 12 '23 03:06 NickDarvey

@andrueastman - Do you have an estimate in which version will this fix be released in?

Dethras avatar Jun 23 '23 08:06 Dethras

It seems the bug is fixed, right?

23W avatar Mar 17 '25 10:03 23W