You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The FluentHttpClient already has all the necessary ingredients to enable a developer to download a file from a given URI but it's not easy to figure out how to do it and it involves writing several lines of code. Additionally, there is no built-in way to report progress when a large file is being downloaded.
I suggest we make the scenario of downloading a file much easier by adding an extension method which would take care of downloading content from a given URI, saving the downloaded data to a file and, optionally, reporting progress as the data is being downloaded with a single line of code. Something along the lines of await client.DownloadFileAsync(...);.
The improvement I am envisioning would enable developers to download a file with the following code:
varclient=newFluentClient("https://proof.ovh.net/");varresource="files/1Mb.dat";// this is the resource we want to downloadvarfilePath=Path.Combine(Path.GetTempPath(),"1Mb.dat");// this is the path where we want to save the downloaded filevarbufferSize=4096;// this is the size of the buffer we will use to read the response streamvarprogress=newProgress<double>(percent =>{Debug.WriteLine($"Download progress: {percent}%");});// this is the progress reporter that will be invoked during the download// Download the resource and save it locally with a single line of code:awaitclient.DownloadFileAsync(resource,filePath,bufferSize,progress);
Activity
Fix test download file not deleted (Pathoschild#135)
Fix running new integration test in .NET 4.5.2 (Pathoschild#135)
Fix running new integration test in parallel (Pathoschild#135)
Fix potential deadlock in some older apps (Pathoschild#135)
Fix edge cases with progress tracking (Pathoschild#135)
Use the `AsStream()` extension (Pathoschild#135)
Throttle download progress reports (Pathoschild#135)