Has anyone seen a solution where they can inspect the progress of file downloads from the server side of a dotnet Core WebApplication? The use case I have is:
- A client GUI application spins up the web server with the code at the bottom of this post.
- Another thread commands an IoT device to download the file.
- The GUI application shows the progress of the download.
Is anyone aware of any hook or event I can use to inform some progress indicator on the GUI? Please let me know! Thank you very much.
Here’s the code. It’s a very minimal function that serves some static files using basic dotnet.
private void RunServer(string configPath)
{
var builder = WebApplication.CreateBuilder();
var app = builder.Build();
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(configPath),
ServeUnknownFileTypes = true,
DefaultContentType = "text/plain"
});
app.Run(FileServer);
}
I’ve tried using the built-in OnPrepareResponse
event, but that only shows the file request before the headers are sent and doesn’t give me any insight into the download itself. I also read the docs for the static file middleware and I don’t see anything that fits this use case.
Anything helps! Thank you again.
Graham Roese is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.