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 :
C#
[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 };
}C#
result I need file as on image :
Sachin SinghRank #66 · 26.2K reputationPosted Nov 20, 2020, 8:53 PM EST
ahmed elbarbaryRank #1,060 · 1.8K reputationPosted Nov 21, 2020, 4:02 AM EST
Mageshwaran RRank #411 · 6.1K reputationPosted Nov 21, 2020, 4:49 AM EST
ahmed elbarbaryRank #1,060 · 1.8K reputationPosted Nov 21, 2020, 7:39 AM EST