using Microsoft.AspNetCore.Mvc; namespace backend.Controllers { [Route("api/excelupload")] [ApiController] public class ExcelUpload : ControllerBase { private readonly IConfiguration _config; public ExcelUpload(IConfiguration config) { _config = config; } [HttpPost] public void ProcessUpload(IFormFile file) { // TODO : Add some header validation to make sure it comes from a real user if (file == null) { Console.WriteLine("fail: FILE IS NULL"); return; } string dataFileName = Path.GetFileName(file.FileName); string curDate = DateTime.Now.ToString("u"); string saveToPath = Path.Combine(_config.GetValue("UploadSavePath"), curDate + '_' + dataFileName); using (FileStream stream = new FileStream(saveToPath, FileMode.Create)) { file.CopyTo(stream); Console.WriteLine($"Saved to {saveToPath}."); } } } }