public ActionResult SubirPrueba([FromBody] SubirPruebaDTO file) { try { var ADN_MON_GUA_V2 = _configuration.GetValue <string>("ADN_MON_GUA_V2"); var data = _pruebaService.SubirArchivo(file); var resultado = _pruebaService.ProcesarPrueba(data, ADN_MON_GUA_V2); if (resultado) { return(Ok(new ResponseDTO() { type = "I", message = "Positivo para Mon-Gua V2" })); } else { return(Ok(new ResponseDTO() { type = "I", message = "Negativo para Mon-Gua V2" })); } }catch (Exception ex) { return(Ok(new ResponseDTO() { type = "E", message = "Ocurrio un error procesando la prueba" })); } }
public string SubirArchivo(SubirPruebaDTO data) { string dataFile = data.file.Substring(data.file.LastIndexOf(',') + 1); string path = @"C:\monguapp\PruebasADN\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string FileName = (DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + data.cedula + ".txt").ToLower(); string file = path + FileName; byte[] tempBytes = Convert.FromBase64String(dataFile); File.WriteAllBytes(file, tempBytes); return(file); }