0

I'm trying to get a file which size is 100MB and return a stream result. I have to wait for "Save as..." window for about 1 minute until it is fully downloaded on server side and then after choosing file name and accepting - it saves very quickly without showing progress. But when I return a file from file system as FilePathResult, it works good.

Example:

public async Task<FileResult> GetFile()
{
    HttpClient client = new HttpClient();
    var response = await client.GetAsync("https://speed.hetzner.de/1GB.bin");
    var stream = await response.Content.ReadAsStreamAsync();

    return File(stream, "application/zip");
}

What should I do to display "Save as..." window straight away and then see how much bytes were actually downloaded?

Governor
  • 27
  • 5

1 Answers1

1

Please see this question for a solution: C# Stream Response from 3rd party, minimal buffering

benq143
  • 301
  • 2
  • 6