public IActionResult Decompress([FromForm] IFormFile file)
 {
     try
     {
         string path = env.ContentRootPath + "\\" + file.FileName;
         using var saver = new FileStream(path, FileMode.Create);
         file.CopyTo(saver);
         using var reader = new StreamReader(saver);
         saver.Position   = 0;
         var text       = reader.ReadToEnd();
         var compressor = new LZWCompressor(env.ContentRootPath);
         path = compressor.Decompress(text);
         var fileStream = new FileStream(path, FileMode.OpenOrCreate);
         return(File(fileStream, "text/plain"));
     }
     catch
     {
         return(StatusCode(500));
     }
 }
Beispiel #2
0
            public void Post(string RServerPath)
                {
                string WServerPath = "";

                if (RServerPath != "")
                {
                    /*All the pre-compress path preparation*/
                    LZWCompressor lz = new LZWCompressor();
                    string        ServerDirectory = Directory.GetCurrentDirectory();
                    string        path            = Path.Combine(ServerDirectory, "Decompress/");
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    WServerPath = path + Path.GetFileName(RServerPath);
                    /*Compress the file*/
                    lz.Decompress(RServerPath, WServerPath);

                    /*adds the compression to the history*/
                    string HistLine = lz.GetFilesMetrics(Path.GetFileName(RServerPath), RServerPath, WServerPath);
                    History.AddToHistory(HistLine);
                    this.WriteOnHistory(HistLine);
                }
            }