I have the following code in my Controller
class:
[HttpPost]
public async Task<IActionResult> GetDataFile(string id, [FromBody] DataLog log)
{
FileStream fileStream = System.IO.File.OpenRead($"{dataFile}_{id}.log");
//using a using block or Close prevents the download...
return File(fileStream, "application/octet-stream");
}
The file should exist temporarily, so when the client finished with the download, the server should delete the file.
I know that while the stream is open, I can't close it.
What callback should I use? Is there a best practice for this?