public IActionResult Upload(string converter = null) { try { Console.WriteLine(converter); var file = Request.Form.Files[0]; Console.WriteLine(Request.Headers["Authorization"]); var tempPath = Path.Combine(Path.GetTempPath(), "Resources", "Images"); Directory.CreateDirectory(tempPath); if (file.Length > 0) { var fileName = file.FileName.Trim(); var fullPath = Path.Combine(tempPath, fileName); Console.WriteLine(fullPath); using (var stream = new FileStream(fullPath, FileMode.Create)) { file.CopyTo(stream); } // start the importer lifenizer.Import(fullPath, converter); return(Ok(new { tempPath })); } else { return(BadRequest()); } } catch (Exception ex) { return(StatusCode(500, $"Internal server error: {ex}")); } }
public void ImportGuess() { var converterFactory = new Mock <IConverterFactory>(); converterFactory.Setup(cf => cf.ConvertFile(It.IsAny <string>(), null)) .Returns(CONVERSATION); ConverterFactory.Instance = converterFactory.Object; lifenizer.Import(IMPORT_FILE_NAME); converterFactory.Verify(c => c.ConvertFile(It.IsAny <string>(), null), Times.Once); importer.Verify(i => i.Import(IMPORT_FILE_NAME), Times.Once); storer.Verify(i => i.SaveFile("b", CONVERSATION), Times.Once); indexer.Verify(i => i.IndexSingle(CONVERSATION), Times.Once); }