add all change in now.

This commit is contained in:
2025-08-29 23:17:58 +10:00
parent be2756d85f
commit 6cea606cc2
22 changed files with 259 additions and 63 deletions
@@ -14,10 +14,12 @@ public class FileUploadController : ControllerBase
{
private readonly IWebHostEnvironment _hostingEnvironment;
private readonly ImportPersonRepository _importPersonRepository;
public FileUploadController(IWebHostEnvironment hostingEnvironment, ImportPersonRepository importPersonRepository)
private readonly IConfiguration _config;
public FileUploadController(IWebHostEnvironment hostingEnvironment, ImportPersonRepository importPersonRepository, IConfiguration config)
{
_hostingEnvironment = hostingEnvironment;
_importPersonRepository = importPersonRepository;
_config = config;
}
[HttpPost("UploadFile")]
@@ -31,9 +33,11 @@ public class FileUploadController : ControllerBase
try
{
// Define the upload directory
// var uploadsFolder = Path.Combine(_hostingEnvironment.WebRootPath, "uploads");
var uploadsFolder = Path.Combine(_hostingEnvironment.ContentRootPath, "uploads");
// var uploadsFolder = Path.Combine(_hostingEnvironment.WebRootPath, "uploads");
string importFolder = _config.GetValue<string>("ImportFolder");
var uploadsFolder = Path.Combine(_hostingEnvironment.ContentRootPath, importFolder);
if (!Directory.Exists(uploadsFolder))
{
Directory.CreateDirectory(uploadsFolder);
@@ -50,9 +54,15 @@ public class FileUploadController : ControllerBase
{
// await file.CopyToAsync(stream);
await file.CopyToAsync(stream);
output = await _importPersonRepository.ImportPerson(stream, "Sheet1");
// output = await _importPersonRepository.ImportPerson(stream, "Sheet1");
}
using (var stream = new MemoryStream())
{
await file.CopyToAsync(stream);
output = await _importPersonRepository.ImportPerson(stream, "Sheet1");
}
//return Ok(new { FileName = uniqueFileName, FilePath = filePath });
return Ok(output);