public ActionResult DecompressFile([FromForm] IFormFile file) { try { string file_path = environment.ContentRootPath + $"\\Data\\temporal\\{file.FileName}"; string output_file_path = environment.ContentRootPath + $"\\Data\\compressions\\{file.FileName}"; FileManage _file = new FileManage(); //Save the file in the server _file.SaveFile(file, file_path); //Get the original file name string file_name = _file.GetOriginalName(environment.ContentRootPath, file.FileName); //Decompress the file previosly saved _file.DecompressFile(file_path, file_name); //Delete the original file _file.DeleteFile(file_path); string path = environment.ContentRootPath + $"\\Data\\decompressions\\{file_name}"; FileStream result = new FileStream(path, FileMode.Open); return(File(result, "text/plain", file_name)); } catch (Exception) { return(StatusCode(500)); } }
public string DecompressFile(FileModel downloadFile) { FileManage _file = new FileManage(); //Decompress the file previosly saved string file_name = _file.DecompressFile(downloadFile); string path = environment.ContentRootPath + $"\\Data\\decompressions\\{file_name}"; return(path); }