public IActionResult ToggleStarred([FromBody] FileManagerCustomContent args) { string jsonPath = this.basePath + "\\wwwroot\\User\\star.json"; StreamReader reader = new StreamReader(jsonPath); string jsonData = reader.ReadToEnd(); reader.Dispose(); List <string> starredFiles = JsonConvert.DeserializeObject <List <string> >(jsonData) ?? new List <string>(); string path = args.Path.Replace(Path.DirectorySeparatorChar, '/'); if (args.Starred && !starredFiles.Contains(path)) { starredFiles.Add(path); } else if (!args.Starred && starredFiles.Contains(path)) { starredFiles.Remove(path); } jsonData = JsonConvert.SerializeObject(starredFiles); System.IO.File.WriteAllText(jsonPath, jsonData); return(Content("")); }
public object FileOperations([FromBody] FileManagerCustomContent args) { switch (args.Action) { // Add your custom action here case "read": if ((args.RootType != null) && ((args.RootType == "Recent") /*|| (args.RootType == "Starred")*/)) { FileManagerResponse result1 = this.operation.Search(args.Path, "*", args.ShowHiddenItems, false); result1 = FilterRecentFiles(result1); return(AddStarDetails(result1)); } else if ((args.RootType != null) && (args.RootType == "Starred")) { return(FilterStarred(this.operation.Search(args.Path, "*", args.ShowHiddenItems, false))); } else { return(AddStarDetails(this.operation.GetFiles(args.Path, args.ShowHiddenItems))); } case "delete": FileManagerDirectoryContent[] items1 = args.Data; string[] names1 = args.Names; for (var i = 0; i < items1.Length; i++) { names1[i] = ((items1[i].FilterPath + items1[i].Name).Substring(1)); RemoveStarred(names1[i]); } return(this.operation.ToCamelCase(MoveToTrash(args.Data))); case "copy": case "move": FileManagerResponse response = new FileManagerResponse(); response.Error = new ErrorDetails() { Code = "401", Message = "Restricted to perform this action" }; return(this.operation.ToCamelCase(response)); case "details": if ((args.RootType != null) && ((args.RootType == "Recent") || (args.RootType == "Starred"))) { FileManagerDirectoryContent[] items = args.Data; string[] names = args.Names; for (var i = 0; i < items.Length; i++) { names[i] = ((items[i].FilterPath + items[i].Name).Substring(1)); } return(this.operation.ToCamelCase(this.operation.Details("/", names, args.Data))); } else { return(this.operation.ToCamelCase(this.operation.Details(args.Path, args.Names, args.Data))); } case "create": // Path - Current path where the folder is to be created; Name - Name of the new folder return(this.operation.ToCamelCase(this.operation.Create(args.Path, args.Name))); case "search": // Path - Current path where the search is performed; SearchString - String typed in the searchbox; CaseSensitive - Boolean value which specifies whether the search must be casesensitive if ((args.RootType != null) && ((args.RootType == "Recent"))) { FileManagerResponse result1 = this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive); result1 = FilterRecentFiles(result1); return(AddStarDetails(result1)); } else if ((args.RootType != null) && (args.RootType == "Starred")) { return(FilterStarred(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive))); } else { return(AddStarDetails(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive))); } case "rename": // Path - Current path of the renamed file; Name - Old file name; NewName - New file name if ((args.RootType != null) && (args.RootType == "Recent")) { var items = args.Data; var name = ((items[0].FilterPath + items[0].Name).Substring(1)); var newName = ((items[0].FilterPath + args.NewName).Substring(1)); return(this.operation.ToCamelCase(this.operation.Rename("/", name, newName))); } else { return(this.operation.ToCamelCase(this.operation.Rename(args.Path, args.Name, args.NewName))); } } return(null); }