public async Task <IActionResult> Upload( string upload, string good, string training, ICollection <IFormFile> files ) { var Uploads = Path.Combine(Environment.WebRootPath, "uploads"); if (!Directory.Exists(Uploads)) { Directory.CreateDirectory(Uploads); } List <FileModel> FileNames = new List <FileModel>(); foreach (var FileObject in files) { if (FileObject.Length > 0) { using (var FileStream = new FileStream(Path.Combine(Uploads, FileObject.FileName), FileMode.Create)) { await FileObject.CopyToAsync(FileStream); var image = new FileModel(Path.Combine(Uploads, FileObject.FileName), FileObject.ContentType); FileNames.Add(image); } } } bool?IsGood = null; var isTraining = !string.IsNullOrEmpty(training) && training.Equals("true"); if (!string.IsNullOrEmpty(good)) { IsGood = good.Equals("true"); } if (isTraining) { UploadResponse Result = VisualInspection.Upload(FileNames, (bool)IsGood); ViewData["HttpResponse"] = "Status code: " + (int)Result.HttpResponse.StatusCode + " " + Result.HttpResponse.StatusCode; ViewData["StringMessage"] = Result.HttpResponse.Content; } else { UploadResponse Result = VisualInspection.Upload(FileNames); ViewData["HttpResponse"] = "Status code: " + (int)Result.HttpResponse.StatusCode + " " + Result.HttpResponse.StatusCode; ViewData["StringMessage"] = Result.HttpResponse.Content; } ViewBag.BearerAvailable = VisualInspection.IsAuthorized; ViewBag.Active = "upload"; return(Index()); }