[Solved] Streaming large file across multiple layers

[ad_1]

Found the solution by using HttpClient instead of RestSharp library for downloading the content directly to browser

The code snippet is as below

HttpClient client = new HttpClient();
var fileName = Path.GetFileName(filePath);
var fileDowloadURL = $"API URL";

var stream = await client.GetStreamAsync(fileDowloadURL).ConfigureAwait(false);
// note that at this point stream only contains the header the body content is not read

return new FileStreamResult(stream, "application/octet-stream")
{
    FileDownloadName = fileName
};

1

[ad_2]

solved Streaming large file across multiple layers