public async Task <IActionResult> Post(List <IFormFile> files) { long size = files.Sum(f => f.Length); if (!files.Any()) { return(NotFound()); } //get the first file only var file = files.First(); // full path to file in upload folder var fullUploadPath = Path.Combine(_hostingEnvironment.WebRootPath, "uploads", file.FileName); if (System.IO.File.Exists(fullUploadPath)) { System.IO.File.Delete(fullUploadPath); } if (file.Length > 0) { using (var stream = new FileStream(fullUploadPath, FileMode.Create)) { await file.CopyToAsync(stream); } } var model = new FunRetroSentimentService(_sentimentService).GetAuthorMessagesWithSentimentFromCsv(fullUploadPath); //return Ok(new { count = files.Count, size, fullUploadPath }); return(Ok(new { model, size, filename = HttpUtility.UrlEncode(file.FileName) })); }
public IActionResult Get(string filename) { var filenameDecoded = HttpUtility.UrlDecode(filename); var model = new FunRetroSentimentService(_sentimentService).GetAuthorMessagesWithSentimentFromCsv(filenameDecoded); return(Ok(new { model, filenameDecoded })); }
public IActionResult Results(string filename) { var fileNameDecoded = HttpUtility.UrlDecode(filename); var fullUploadPath = Path.Combine(_hostingEnvironment.WebRootPath, _uploadFolder, fileNameDecoded); var model = new FunRetroSentimentService(_sentimentService).GetAuthorMessagesWithSentimentFromCsv(fullUploadPath); return(View(model)); }