public async Task <IActionResult> DownloadFile([FromQuery] string id, [FromQuery] string file) { try { var memory = new MemoryStream(); using (var stream = await _mongoStreamer.Download(id)) { await stream.CopyToAsync(memory); stream.Close(); } memory.Position = 0; return(new FileStreamResult(memory, _multipartRequestHelper.ContentTypeFromPath(file))); } catch (Exception e) { _logger.LogError($"{DateTime.UtcNow} StackTrace:{e.StackTrace}"); return (BadRequest(new { e.Message, e.StackTrace, ErrorDescription = "Could not get the page initial data." })); } }