Exemple #1
0
        public IActionResult PostFileTxt([FromForm] FileText info)
        {
            if (info == null)
            {
                return(BadRequest());
            }

            info.Date = DateTime.Now;
            _log.Add(info).Wait();
            ProcessFile processFile = new ProcessFile(new ProcessFileTxt());

            try
            {
                Response.Headers.Add("Access-Control-Allow-Origin", new[] { (string)Request.Headers["Origin"] });
                MemoryStream fileProcessed = processFile.FileProcess(info.File);
                return(File(fileProcessed, "text/plain", textFileOutput));
            }
            catch (OutOfMemoryException)
            {
                return(BadRequest());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }