I’m stucked… I’ve read all of the threads about this and can’t make it work and don’t know why…
I’ve a WEB API which should return a large zip file (>2GB), it creates the zip on disk, it’s ok and returns with this:
return new FileStreamResult(new FileStream(Path.Combine(<path_to_file>), FileMode.Open), "application/zip") { FileDownloadName = generatedFileName };
On the client side I’ve a Blazor WASM and getting the result this way:
var request = new HttpRequestMessage(HttpMethod.Get, uri);
request.Headers.Add("session", <session_data>);
... <other headers>
var result = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
if (result.IsSuccessStatusCode)
{
Console.WriteLine("Getting stream...");
var responseStream = await result.Content.ReadAsStreamAsync();
Console.WriteLine("Stream done");
}
When the zip is relatively small (4-500MB) it works well, but when I try to download for example a 3 GB zip, the “Stream done” line never reached, instead of the I’m getting an error in the output:
“TypeError: Failed to fetch at System.Net.Http.BrowserHttpInterop.d__13`1[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at System.Net.Http.BrowserHttpContent.GetResponseData(CancellationToken cancellationToken)
at System.Net.Http.BrowserHttpContent.CreateContentReadStreamAsync()
” and the line number where the ReadAsStreamAsync is.
What can be the problem here? Trying to solve it in the last two days but nothing helps…
Thanks!
I’ve tried everything 🙂
Attila Kiss is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.