public override async Task <IResponseWriter> Execute() { Dictionary <string, FsItemSize> result = new Dictionary <string, FsItemSize>(); int TotalDirectoryCount = 0; int TotalFileCount = 0; long TotalSize = 0; foreach (var item in Targets.Values) { var volume = ElFinder.GetVolume(item); var size = await volume.GetSize(item); result.Add(item, size); TotalDirectoryCount += size.DirectoryCount; TotalFileCount += size.FileCount; TotalSize += size.Size; } return(new JsonResponseWriter(new { dirCnt = TotalDirectoryCount, fileCnt = TotalFileCount, size = TotalSize, sizes = result })); }
public override async Task <IResponseWriter> Execute() { var volume = ElFinder.GetVolume(Target); var items = await volume.GetDirectoryItems(Target); return(new JsonResponseWriter(new { tree = items.OfType <Fs.FsDirectory>().ToArray() })); }
public override async Task <IResponseWriter> Execute() { var volume = ElFinder.GetVolume(Target); var added = await volume.Rename(Target, NewName); return(new JsonResponseWriter(new { added = new Fs.FsBase[] { added }, removed = new string[] { Target } })); }
public override async Task <IResponseWriter> Execute() { var volume = ElFinder.GetVolume(Target); var(stream, filename) = await volume.GetFile(Target); return(new FileResponseWriter(stream, filename)); }
public override async Task <IResponseWriter> Execute() { var volume = ElFinder.GetVolume(Target); var parents = await volume.GetParents(Target, Until); return(new JsonResponseWriter(new { tree = parents })); }
public override async Task <ResponseWriter.IResponseWriter> Execute() { OpenCommandResult result = new OpenCommandResult(); var volume = ElFinder.GetVolume(Target); Fs.FsBase cwd = null; if (volume != null) { cwd = await volume.GetCurrentWorkingDirectory(Target); } string hash = Init ? "default folder" : "#" + Target; if ((cwd == null || !(cwd.Read == 1)) && Init) { volume = ElFinder.Default; Target = volume.DefaultPath; cwd = await volume.GetCurrentWorkingDirectory(Target); } if (Init) { result.Api = 2.1046f; } List <Fs.FsBase> files = new List <Fs.FsBase>(); result.Cwd = cwd; files.AddRange(await volume.GetDirectoryItems(Target)); result.UplMaxSize = "1M"; result.UplMaxFile = 3; if (Tree) { List <Fs.FsBase> roots = new List <Fs.FsBase>(); foreach (var r in ElFinder.Volumes) { if (files.FirstOrDefault(f => f.Hash == r.Root.Hash) == null) { files.Add(r.Root); } } } result.Files = files.ToArray(); result.Options.UploadMime = new Fs.UploadMimeOptions { Allow = new string[] { "image/x-ms-bmp", "image/gif", "image/jpeg", "image/png", "image/x-icon", "text/plain" }, Deny = new string[] { "all" }, FirstOrder = "deny" }; var writer = new ResponseWriter.JsonResponseWriter(result); return(writer); }
public ActionResult Files(HttpPostedFileBase files) { string cmd = this.Request.Params["cmd"].ToString(); //ControllerContext.RouteData ElFinder el = new ElFinder(options); return Content(el.Run(this.Request)); }
public ActionResult Files() { string cmd = this.Request.Params["cmd"].ToString(); //ControllerContext.RouteData ElFinder el = new ElFinder(options); string contentType = "Content-Type: " + cmd == "upload" ? "text/html" : "application/json"; return Content(el.Run(this.Request), contentType); }
public override async Task <IResponseWriter> Execute() { var volume = ElFinder.GetVolume(Target); var items = await volume.GetDirectoryItems(Target); Dictionary <string, string> result = new Dictionary <string, string>(); foreach (var item in items) { if (Intersect.Length == 0 || Intersect.Contains(item.Name)) { result.Add(item.Hash, item.Name); } } return(new JsonResponseWriter(new { list = result })); }
private async Task <IResponseWriter> ChunkUpload() { System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"^(.*).(\d+)_(\d+).part$"); var match = regex.Match(Chunk); if (match.Success) { string filename = match.Groups[1].Value; int part = Convert.ToInt32(match.Groups[2].Value); int total = Convert.ToInt32(match.Groups[3].Value); string[] ranges = Range.Split(','); int startByte = Convert.ToInt32(ranges[0]); int chunkLenght = Convert.ToInt32(ranges[1]); int totalBytes = Convert.ToInt32(ranges[2]); byte[] chunkContent; using (var stream = Files[0].OpenReadStream()) using (var sr = new System.IO.BinaryReader(stream)) { chunkContent = sr.ReadBytes(chunkLenght); } bool chunkMerged = StoreChunk(filename, startByte, chunkLenght, totalBytes, chunkContent); if (chunkMerged) { return(new JsonResponseWriter(new { added = new int[0], _chunkmerged = filename, _name = filename })); } else { return(new JsonResponseWriter(new { added = new int[0] })); } } else { var volume = ElFinder.GetVolume(Target); var hashPath = UploadPaths != null && UploadPaths.Length > 0 ? UploadPaths[0] : Target; var item = chunkStorage[Chunk]; chunkStorage.Remove(Chunk); var added = await volume.Upload(hashPath, Chunk, item.Stream); return(new JsonResponseWriter(new { added = new Fs.FsBase[] { added } })); } }
public override async Task <IResponseWriter> Execute() { Dictionary <string, string> images = new Dictionary <string, string>(); foreach (var target in Targets) { var volume = ElFinder.GetVolume(target); var(stream, filename) = await volume.GetFile(target); using (stream) { var tmbName = volume.CreateTmb(stream, filename); images.Add(target, tmbName); } } return(new JsonResponseWriter(new { images })); }
public override async Task <IResponseWriter> Execute() { List <string> successfullyRemoved = new List <string>(); foreach (var target in Targets) { var volume = ElFinder.GetVolume(target); try { await volume.Delete(target); successfullyRemoved.Add(target); } catch (Exception e) { //log } } return(new JsonResponseWriter(new { removed = successfullyRemoved })); }
public override async Task <IResponseWriter> Execute() { if (IsChunkUpload()) { return(await ChunkUpload()); } var volume = ElFinder.GetVolume(Target); List <Fs.FsBase> uploadedFiles = new List <Fs.FsBase>(); for (int i = 0; i < Files.Count; i++) { var file = Files[i]; var hashPath = UploadPaths != null && UploadPaths.Length > i ? UploadPaths[i] : Target; System.IO.MemoryStream ms = new System.IO.MemoryStream((int)file.Length); file.CopyTo(ms); uploadedFiles.Add(await volume.Upload(hashPath, file.FileName, ms)); } return(new JsonResponseWriter(new { added = uploadedFiles.ToArray() })); }
public override async Task <IResponseWriter> Execute() { var result = new MkDirCommandResult(); var volume = ElFinder.GetVolume(Target); if (volume != null) { if (!string.IsNullOrEmpty(DirectoryName)) { var dir = await volume.CreateDirectory(Target, DirectoryName); result.Added = new Fs.FsDirectory[] { dir }; } else { result.Hashes = new Dictionary <string, string>(); List <Fs.FsDirectory> dirs = new List <Fs.FsDirectory>(); foreach (var item in Dirs) { var d = await volume.CreateDirectory(Target, item); dirs.Add(d); result.Hashes.Add(item, d.Hash); } result.Added = dirs.ToArray(); } result.Changed = new Fs.FsDirectory[] { (Fs.FsDirectory) await volume.GetCurrentWorkingDirectory(Target) }; return(new JsonResponseWriter(result)); } else { throw new InvalidOperationException(); } }
public OpenCommand(NameValueCollection cmdParams, ElFinder elFinder) : base(cmdParams, elFinder) { Name = "open"; }
public RmCommand(NameValueCollection cmdParams, ElFinder elFinder) : base(cmdParams, elFinder) { }
public Command(NameValueCollection cmdParams, ElFinder elFinder) { CmdParams = cmdParams; ElFinder = elFinder; InitCommand(); }
public static ICommand CreateCommand(string name, NameValueCollection cmdParams, ElFinder elFinder, IFormFileCollection files) { switch (name) { case "open": return(new OpenCommand(cmdParams, elFinder)); case "mkdir": return(new MkDirCommand(cmdParams, elFinder)); case "tree": return(new TreeCommand(cmdParams, elFinder)); case "file": return(new FileCommand(cmdParams, elFinder)); case "parents": return(new ParentsCommand(cmdParams, elFinder)); case "upload": return(new UploadCommand(cmdParams, elFinder, files)); case "ls": return(new LsCommand(cmdParams, elFinder)); case "rename": return(new RenameCommand(cmdParams, elFinder)); case "rm": return(new RmCommand(cmdParams, elFinder)); case "size": return(new SizeCommand(cmdParams, elFinder)); case "tmb": return(new TmbCommand(cmdParams, elFinder)); default: throw new InvalidOperationException($"Command not found. Command name: {name}"); } }
public UploadCommand(NameValueCollection cmdParams, ElFinder elFinder, IFormFileCollection files) : base(cmdParams, elFinder) { Files = files; }