I work on asp.net core 2.2 Web Api I face issue I can't see Downloaded file on download Path and I can't see it After download on browser
download file success on path i give it but not make download on download path and I can't see it to open it directly
my code I use it for download is :
- [HttpPost, DisableRequestSizeLimit]
- public IActionResult Upload()
- {
- try
- {
- var DisplayFileName = Request.Form.Files[0];
- string fileName = DisplayFileName.FileName.Replace(".xlsx", "-") + Guid.NewGuid().ToString() + ".xlsx";
- string exportPath = myValue2 + "\\" + fileName;
-
- if (exportPath != "")
- {
- ex.DownloadOutPut(exportPath);
- }
-
-
- }
- return Ok(new { dbPath });
- }
- else
- {
- return BadRequest();
- }
- }
- catch (Exception ex)
- {
- return StatusCode(500, $"Internal server error: {ex}");
- }
- }
- function for download I use it
- public FileStreamResult DownloadOutPut(string path)
- {
-
-
- var filename = System.IO.Path.GetFileName(path);
- var mimeType = "application/octet-stream";
- var stream = System.IO.File.OpenRead(path);
-
-
- return new FileStreamResult(stream, mimeType) { FileDownloadName = filename };
- }
result I need file as on image :
