public object FileOperations([FromBody] FileManagerDirectoryContent args)
        {
            if (args.Action is "delete" or "rename")
            {
                if ((args.TargetPath == null) && (args.Path == ""))
                {
                    FileManagerResponse response = new()
                    {
                        Error = new ErrorDetails {
                            Code = "401", Message = "Restricted to modify the root folder."
                        }
                    };
                    return(operation.ToCamelCase(response));
                }
            }

            return(args.Action switch
            {
                "read" => operation.ToCamelCase(operation.GetFiles(args.Path, args.ShowHiddenItems)),
                "delete" => operation.ToCamelCase(operation.Delete(args.Path, args.Names)),
                "copy" => operation.ToCamelCase(operation.Copy(args.Path, args.TargetPath, args.Names,
                                                               args.RenameFiles, args.TargetData)),
                "move" => operation.ToCamelCase(operation.Move(args.Path, args.TargetPath, args.Names,
                                                               args.RenameFiles, args.TargetData)),
                "details" => operation.ToCamelCase(operation.Details(args.Path, args.Names, args.Data)),
                "create" => operation.ToCamelCase(operation.Create(args.Path, args.Name)),
                "search" => operation.ToCamelCase(operation.Search(args.Path, args.SearchString,
                                                                   args.ShowHiddenItems, args.CaseSensitive)),
                "rename" => operation.ToCamelCase(operation.Rename(args.Path, args.Name, args.NewName)),
                _ => null
            });
        private async void MoveSubFolder(FileManagerDirectoryContent subfolder, string targetPath)
        {
            CloudBlobDirectory blobDirectory = container.GetDirectoryReference(targetPath);
            BlobResultSegment  items         = await AsyncReadCall(subfolder.Path, "Paste");

            await CreateFolderAsync(targetPath, subfolder.Name);

            targetPath = targetPath + subfolder.Name + "/";
            foreach (IListBlobItem item in items.Results)
            {
                if (item.GetType() == typeof(CloudBlockBlob))
                {
                    CloudBlockBlob BlobItem   = (CloudBlockBlob)item;
                    string         name       = BlobItem.Name.Replace(subfolder.Path + "/", "");
                    string         sourcePath = BlobItem.Name.Replace(name, "");
                    await MoveItems(sourcePath, targetPath, name, null);
                }
                if (item.GetType() == typeof(CloudBlobDirectory))
                {
                    CloudBlobDirectory          BlobItem   = (CloudBlobDirectory)item;
                    FileManagerDirectoryContent itemDetail = new FileManagerDirectoryContent();
                    itemDetail.Name = BlobItem.Prefix.Replace(subfolder.Path, "").Replace("/", "");
                    itemDetail.Path = subfolder.Path + "/" + itemDetail.Name;
                    CopySubFolder(itemDetail, targetPath);
                }
            }
        }
示例#3
0
        public object FTPFileOperations([FromBody] FileManagerDirectoryContent args)
        {
            switch (args.Action)
            {
            case "read":
                return(this.operation.ToCamelCase(this.operation.GetFiles(args.Path, args.ShowHiddenItems, args.Data)));

            case "delete":
                return(this.operation.ToCamelCase(this.operation.Delete(args.Path, args.Names, args.Data)));

            case "copy":
                return(this.operation.ToCamelCase(this.operation.Copy(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData, args.Data)));

            case "move":
                return(this.operation.ToCamelCase(this.operation.Move(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData, args.Data)));

            case "details":
                return(this.operation.ToCamelCase(this.operation.Details(args.Path, args.Names, args.Data)));

            case "create":
                return(this.operation.ToCamelCase(this.operation.Create(args.Path, args.Name, args.Data)));

            case "search":
                return(this.operation.ToCamelCase(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive, args.Data)));

            case "rename":
                return(this.operation.ToCamelCase(this.operation.Rename(args.Path, args.Name, args.NewName, false, args.Data)));
            }
            return(null);
        }
示例#4
0
        public ActionResult AzureUpload(FileManagerDirectoryContent args)
        {
            if (args.Path != "")
            {
                string startPath    = "<--blobPath-->";
                string originalPath = ("<--filePath-->").Replace(startPath, "");
                args.Path = (originalPath + args.Path).Replace("//", "/");
                //----------------------
                //For example
                //string startPath = "https://azure_service_account.blob.core.windows.net/files/";
                //string originalPath = ("https://azure_service_account.blob.core.windows.net/files/Files").Replace(startPath, "");
                //args.Path = (originalPath + args.Path).Replace("//", "/");
                //----------------------
            }
            FileManagerResponse uploadResponse = operation.Upload(args.Path, args.UploadFiles, args.Action, args.Data);

            if (uploadResponse.Error != null)
            {
                Response.Clear();
                Response.ContentType = "application/json; charset=utf-8";
                Response.StatusCode  = Convert.ToInt32(uploadResponse.Error.Code);
                Response.HttpContext.Features.Get <IHttpResponseFeature>().ReasonPhrase = uploadResponse.Error.Message;
            }
            return(Json(""));
        }
        public IActionResult SQLDownload(string downloadInput)
        {
            FileManagerDirectoryContent args = JsonConvert.DeserializeObject <FileManagerDirectoryContent>(downloadInput);

            args.Path = (args.Path);
            return(operation.Download(args.Path, args.Names, args.Data));
        }
        public string[] ConvertToPDF([FromBody] FileManagerDirectoryContent args)
        {
            string fileLocation = this.baseLocation + args.Path.Replace("/", "\\");

            // If document get open from zip file, we have maintained the extracted document path in TargetPath property.
            if (args.TargetPath != null)
            {
                fileLocation = args.TargetPath;
            }
            List <string> returnArray = new List <string>();

            using FileStream fs = new FileStream(fileLocation, FileMode.Open, FileAccess.Read);
            //Open the existing presentation
            IPresentation presentation = Syncfusion.Presentation.Presentation.Open(fs);
            //Convert the PowerPoint document to PDF document.
            PdfDocument pdfDocument = PresentationToPdfConverter.Convert(presentation);
            //Save the document as a stream and retrun the stream
            MemoryStream stream = new MemoryStream();

            //Save the created PowerPoint document to MemoryStream
            pdfDocument.Save(stream);
            stream.Position = 0;
            returnArray.Add("data:application/pdf;base64," + Convert.ToBase64String(stream.ToArray()));
            //Dispose the document objects.
            presentation.Dispose();
            pdfDocument.Dispose();
            stream.Dispose();
            return(returnArray.ToArray());
        }
示例#7
0
        public FileManagerResponse GetFiles()
        {
            FileManagerResponse         readResponse = new FileManagerResponse();
            FileManagerDirectoryContent cwd          = new FileManagerDirectoryContent();
            String        fullPath  = (this.baseLocation + "/Trash");
            DirectoryInfo directory = new DirectoryInfo(fullPath);

            cwd.Name         = "Trash";
            cwd.Size         = 0;
            cwd.IsFile       = false;
            cwd.DateModified = directory.LastWriteTime;
            cwd.DateCreated  = directory.CreationTime;
            cwd.HasChild     = false;
            cwd.Type         = directory.Extension;
            cwd.FilterPath   = "/";
            cwd.Permission   = null;
            readResponse.CWD = cwd;
            string jsonPath = this.basePath + "\\wwwroot\\User\\trash.json";
            string jsonData = System.IO.File.ReadAllText(jsonPath);
            List <TrashContents> DeletedFiles        = JsonConvert.DeserializeObject <List <TrashContents> >(jsonData) ?? new List <TrashContents>();
            List <FileManagerDirectoryContent> files = new List <FileManagerDirectoryContent>();

            foreach (TrashContents file in DeletedFiles)
            {
                files.Add(file.Data);
            }
            readResponse.Files = files;
            return(readResponse);
        }
示例#8
0
        // Processing the Download operation
        public ActionResult Download(string downloadInput)
        {
            FileManagerDirectoryContent args = JsonConvert.DeserializeObject <FileManagerDirectoryContent>(downloadInput);

            //Invoking download operation with the required paramaters
            // path - Current path where the file is downloaded; Names - Files to be downloaded;
            return(operation.Download(args.Path, args.Names));
        }
        public IActionResult ExtractZip([FromBody] FileManagerDirectoryContent args)
        {
            DeleteDirectoryContent();
            string zipLocation = this.baseLocation + args.Path;

            ZipFile.ExtractToDirectory(zipLocation, this.tempDir);
            return(Content("Extracted"));
        }
示例#10
0
        public ActionResult FileOperations(FileManagerDirectoryContent args)
        {
            // Restricting modification of the root folder
            if (args.Action == "delete" || args.Action == "rename")
            {
                if ((args.TargetPath == null) && (args.Path == ""))
                {
                    FileManagerResponse response = new FileManagerResponse();
                    ErrorDetails        er       = new ErrorDetails
                    {
                        Code    = "401",
                        Message = "Restricted to modify the root folder."
                    };
                    response.Error = er;
                    return(Json(operation.ToCamelCase(response)));
                }
            }
            // Processing the File Manager operations
            switch (args.Action)
            {
            case "read":
                // Path - Current path; ShowHiddenItems - Boolean value to show/hide hidden items
                return(Json(operation.ToCamelCase(this.operation.GetFiles(args.Path, args.ShowHiddenItems))));

            case "delete":
                // Path - Current path where of the folder to be deleted; Names - Name of the files to be deleted
                return(Json(operation.ToCamelCase(this.operation.Delete(args.Path, args.Names))));

            case "copy":
                //  Path - Path from where the file was copied; TargetPath - Path where the file/folder is to be copied; RenameFiles - Files with same name in the copied location that is confirmed for renaming; TargetData - Data of the copied file
                return(Json(operation.ToCamelCase(this.operation.Copy(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData))));

            case "move":
                // Path - Path from where the file was cut; TargetPath - Path where the file/folder is to be moved; RenameFiles - Files with same name in the moved location that is confirmed for renaming; TargetData - Data of the moved file
                return(Json(operation.ToCamelCase(this.operation.Move(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData))));

            case "details":
                // Path - Current path where details of file/folder is requested; Name - Names of the requested folders
                if (args.Names == null)
                {
                    args.Names = new string[] { };
                }
                return(Json(operation.ToCamelCase(this.operation.Details(args.Path, args.Names))));

            case "create":
                // Path - Current path where the folder is to be created; Name - Name of the new folder
                return(Json(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
                return(Json(operation.ToCamelCase(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
                return(Json(operation.ToCamelCase(this.operation.Rename(args.Path, args.Name, args.NewName))));
            }
            return(null);
        }
 public IActionResult AzureGetImage(FileManagerDirectoryContent args, [FromRoute] string newroot)
 {
     if (newroot != null)
     {
         args.Path = "/" + newroot + args.Path.Replace(newroot, "");
         args.Path = args.Path.Replace("//", "/");
     }
     return(this.operation.GetImage(args.Path, args.Id, true, null, args.Data));
 }
示例#12
0
        public object GetImage(FileManagerDirectoryContent args)
        {
            //update FileAttribute (retrieval)
            var fileAttribute = fileAttributeRepository.Find(null).Items?.Where(q => q.Name == FileAttributes.RetrievalCount.ToString() &&
                                                                                q.ServerFileId == Guid.Parse(args.Id)).FirstOrDefault();

            fileAttribute.AttributeValue += 1;
            fileAttributeRepository.Update(fileAttribute);

            return(this.operation.GetImage(args.Path, args.Id, false, null, null));
        }
示例#13
0
 public ActionResult AzureUpload(FileManagerDirectoryContent args)
 {
     if (args.Path != "")
     {
         string startPath    = _blobPath;
         string originalPath = _filePath.Replace(startPath, "");
         args.Path = (originalPath + args.Path).Replace("//", "/");
     }
     _operation.Upload(args.Path, args.UploadFiles, args.Action, args.Data);
     return(Json(""));
 }
示例#14
0
 public ActionResult AzureUpload(FileManagerDirectoryContent args)
 {
     if (args.Path != "")
     {
         string originalPath = "https://ej2filemanager.blob.core.windows.net/files/Files/";
         string startPath    = "https://ej2filemanager.blob.core.windows.net/files/";
         originalPath = originalPath.Replace(startPath, "");
         args.Path    = (originalPath + args.Path).Replace("//", "/");
     }
     operation.Upload(args.Path, args.UploadFiles, args.Action, args.Data);
     return(Json(""));
 }
示例#15
0
        public IActionResult Download(string downloadInput)
        {
            FileManagerDirectoryContent args = JsonConvert.DeserializeObject <FileManagerDirectoryContent>(downloadInput);

            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(operation.Download("/", names));
        }
        // To get the file details
        private FileManagerDirectoryContent GetFileDetails(string targetPath, FileManagerDirectoryContent fileDetails)
        {
            FileManagerDirectoryContent entry = new FileManagerDirectoryContent();

            entry.Name       = fileDetails.Name;
            entry.Type       = fileDetails.Type;
            entry.IsFile     = fileDetails.IsFile;
            entry.Size       = fileDetails.Size;
            entry.HasChild   = fileDetails.HasChild;
            entry.FilterPath = targetPath;
            return(entry);
        }
 public IActionResult GetImage(FileManagerDirectoryContent args)
 {
     try
     {
         return(Ok(manager.GetImage(args)));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("Get Image", ex.Message);
         return(BadRequest(ModelState));
     }
 }
 public IActionResult FileOperations([FromBody] FileManagerDirectoryContent args)
 {
     try
     {
         return(Ok(manager.LocalFileStorageOperation(args)));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("File Operations", ex.Message);
         return(BadRequest(ModelState));
     }
 }
        public object AzureDownload(string downloadInput, [FromRoute] string newroot)
        {
            FileManagerDirectoryContent args = JsonConvert.DeserializeObject <FileManagerDirectoryContent>(downloadInput);

            if (newroot != null)
            {
                string destFolder = args.Path.Replace(baseFolder, "").Replace("/", "");
                args.Path       = (baseFolder + "/" + newroot + "/" + destFolder + "/").Replace("//", "/");
                args.TargetPath = (baseFolder + "/" + newroot + "/" + destFolder).Replace("//", "/");
            }
            return(operation.Download(args.Path, args.Names, args.Data));
        }
        //Updates the file system in the firebase database
        public void updateDBNode(FileManagerDirectoryContent CreateData, int idValue)
        {
            var createdString = JsonConvert.SerializeObject(CreateData, new JsonSerializerSettings
            {
                ContractResolver = new DefaultContractResolver
                {
                    NamingStrategy = new CamelCaseNamingStrategy()
                }
            });

            this.firebaseAPI.Patch(this.APIURL + "/" + this.rootNode + "/", "{" + (idValue + 1).ToString() + ":" + createdString + "}");
        }
        private void copyFolderItems(FileManagerDirectoryContent item, string targetID)
        {
            DriveService service = GetService();

            ChildrenResource.ListRequest request = service.Children.List(item.Id);
            ChildList children = request.Execute();

            foreach (ChildReference child in children.Items)
            {
                var childDetails = service.Files.Get(child.Id).Execute();
                if (childDetails.MimeType == "application/vnd.google-apps.folder")
                {
                    File file = new File()
                    {
                        Title   = childDetails.Title,
                        Parents = new List <ParentReference> {
                            new ParentReference()
                            {
                                Id = targetID
                            }
                        },
                        MimeType = "application/vnd.google-apps.folder"
                    };
                    request.Fields = "id";
                    File SubFolder = (service.Files.Insert(file)).Execute();
                    FileManagerDirectoryContent FileDetail = new FileManagerDirectoryContent();
                    FileDetail.Name         = childDetails.Title;
                    FileDetail.Id           = childDetails.Id;
                    FileDetail.IsFile       = false;
                    FileDetail.Type         = "folder";
                    FileDetail.FilterId     = obtainFilterId(childDetails);
                    FileDetail.HasChild     = getChildrenById(childDetails.Id);
                    FileDetail.DateCreated  = Convert.ToDateTime(childDetails.ModifiedDate);
                    FileDetail.DateModified = Convert.ToDateTime(childDetails.ModifiedDate);
                    copyFolderItems(FileDetail, SubFolder.Id);
                }
                else
                {
                    File SubFile = new File()
                    {
                        Title   = childDetails.Title,
                        Parents = new List <ParentReference> {
                            new ParentReference()
                            {
                                Id = targetID
                            }
                        }
                    };
                    FilesResource.CopyRequest subFilerequest = service.Files.Copy(SubFile, child.Id);
                    subFilerequest.Execute();
                }
            }
        }
示例#22
0
        public object FirebaseRealtimeFileOperations([FromBody] FileManagerDirectoryContent args)
        {
            if (args.Action == "delete" || args.Action == "rename")
            {
                if ((args.TargetPath == null) && (args.Path == ""))
                {
                    FileManagerResponse response = new FileManagerResponse();
                    ErrorDetails        er       = new ErrorDetails
                    {
                        Code    = "401",
                        Message = "Restricted to modify the root folder."
                    };
                    response.Error = er;
                    return(this.operation.ToCamelCase(response));
                }
            }
            switch (args.Action)
            {
            case "read":
                // reads the file(s) or folder(s) from the given path.
                return(this.operation.ToCamelCase(this.operation.GetFiles(args.Path, false, args.Data)));

            case "delete":
                // deletes the selected file(s) or folder(s) from the given path.
                return(this.operation.ToCamelCase(this.operation.Delete(args.Path, args.Names, args.Data)));

            case "copy":
                // copies the selected file(s) or folder(s) from a path and then pastes them into a given target path.
                return(this.operation.ToCamelCase(this.operation.Copy(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData, args.Data)));

            case "move":
                // cuts the selected file(s) or folder(s) from a path and then pastes them into a given target path.
                return(this.operation.ToCamelCase(this.operation.Move(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData, args.Data)));

            case "details":
                // gets the details of the selected file(s) or folder(s).
                return(this.operation.ToCamelCase(this.operation.Details(args.Path, args.Names, args.Data)));

            case "create":
                // creates a new folder in a given path.
                return(this.operation.ToCamelCase(this.operation.Create(args.Path, args.Name, args.Data)));

            case "search":
                // gets the list of file(s) or folder(s) from a given path based on the searched key string.
                return(this.operation.ToCamelCase(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive)));

            case "rename":
                // renames a file or folder.
                return(this.operation.ToCamelCase(this.operation.Rename(args.Path, args.Name, args.NewName, false, args.Data)));
            }
            return(null);
        }
        public string[] OpenFromZip([FromBody] FileManagerDirectoryContent args)
        {
            List <string> returnArray = new List <string>();

            using (FileStream fs = new FileStream(args.Path, FileMode.Open, FileAccess.Read))
            {
                WordDocument document = WordDocument.Load(fs, GetImportFormatType(Path.GetExtension(args.Path).ToLower()));
                string       json     = Newtonsoft.Json.JsonConvert.SerializeObject(document);
                document.Dispose();
                returnArray.Add(json);
                return(ConvertToImages(fs, returnArray, GetDocIOFormatType(Path.GetExtension(args.Path).ToLower())).ToArray());
            }
        }
示例#24
0
        public object GetImage(FileManagerDirectoryContent args)
        {
            string adapter = Configuration["Files:Adapter"];

            if (adapter.Equals(AdapterType.LocalFileStorageAdapter.ToString()))
            {
                return(localFileStorageAdapter.GetImage(args));
            }
            else
            {
                throw new EntityOperationException("Configuration is not set up for local file storage");
            }
        }
示例#25
0
        public object DownloadFile(string downloadInput)
        {
            FileManagerDirectoryContent args = JsonConvert.DeserializeObject <FileManagerDirectoryContent>(downloadInput);

            //update FileAttribute (retrieval)
            var fileAttribute = fileAttributeRepository.Find(null).Items?.Where(q => q.Name == FileAttributes.RetrievalCount.ToString() &&
                                                                                q.ServerFileId == Guid.Parse(args.Id)).FirstOrDefault();

            fileAttribute.AttributeValue += 1;
            fileAttributeRepository.Update(fileAttribute);

            return(operation.Download(args.Path, args.Names, args.Data));
        }
示例#26
0
        // Deletes file(s) or folder(s)
        public async Task <FileManagerResponse> RemoveAsync(string[] names, string path, params FileManagerDirectoryContent[] selectedItems)
        {
            FileManagerResponse removeResponse = new FileManagerResponse();

            List <FileManagerDirectoryContent> details  = new List <FileManagerDirectoryContent>();
            CloudBlobDirectory          directory       = (CloudBlobDirectory)item;
            FileManagerDirectoryContent entry           = new FileManagerDirectoryContent();
            CloudBlobDirectory          sampleDirectory = container.GetDirectoryReference(path);

            foreach (var Fileitem in selectedItems)
            {
                FileManagerDirectoryContent s_item = Fileitem;

                if (s_item.IsFile)
                {
                    path = this.FilesPath.Replace(this.BlobPath, "") + s_item.FilterPath;
                    CloudBlockBlob blockBlob = container.GetBlockBlobReference(path + s_item.Name);
                    await blockBlob.DeleteAsync();

                    entry.Name       = s_item.Name;
                    entry.Type       = s_item.Type;
                    entry.IsFile     = s_item.IsFile;
                    entry.Size       = s_item.Size;
                    entry.HasChild   = s_item.HasChild;
                    entry.FilterPath = path;
                    details.Add(entry);
                }
                else
                {
                    path = this.FilesPath.Replace(this.BlobPath, "") + s_item.FilterPath;
                    CloudBlobDirectory subDirectory = container.GetDirectoryReference(path + s_item.Name);
                    var items = await AsyncReadCall(path + s_item.Name, "Remove");

                    foreach (var item in items.Results)
                    {
                        CloudBlockBlob blockBlob = container.GetBlockBlobReference(path + s_item.Name + "/" + item.Uri.ToString().Replace(subDirectory.Uri.ToString(), ""));
                        await blockBlob.DeleteAsync();

                        entry.Name       = s_item.Name;
                        entry.Type       = s_item.Type;
                        entry.IsFile     = s_item.IsFile;
                        entry.Size       = s_item.Size;
                        entry.HasChild   = s_item.HasChild;
                        entry.FilterPath = path;
                        details.Add(entry);
                    }
                }
            }
            removeResponse.Files = (IEnumerable <FileManagerDirectoryContent>)details;
            return(removeResponse);
        }
示例#27
0
        public object AzureFileOperations([FromBody] FileManagerDirectoryContent args)
        {
            if (args.Path != "")
            {
                string startPath    = "<--blobPath-->";
                string originalPath = ("<--filePath-->").Replace(startPath, "");
                //-----------------
                //For example
                //string startPath = "https://azure_service_account.blob.core.windows.net/files/";
                //string originalPath = ("https://azure_service_account.blob.core.windows.net/files/Files").Replace(startPath, "");
                //-------------------
                args.Path       = (originalPath + args.Path).Replace("//", "/");
                args.TargetPath = (originalPath + args.TargetPath).Replace("//", "/");
            }
            switch (args.Action)
            {
            case "read":
                // Reads the file(s) or folder(s) from the given path.
                return(Json(this.ToCamelCase(this.operation.GetFiles(args.Path, args.ShowHiddenItems, args.Data))));

            case "delete":
                // Deletes the selected file(s) or folder(s) from the given path.
                return(this.ToCamelCase(this.operation.Delete(args.Path, args.Names, args.Data)));

            case "details":
                // Gets the details of the selected file(s) or folder(s).
                return(this.ToCamelCase(this.operation.Details(args.Path, args.Names, args.Data)));

            case "create":
                // Creates a new folder in a given path.
                return(this.ToCamelCase(this.operation.Create(args.Path, args.Name, args.Data)));

            case "search":
                // Gets the list of file(s) or folder(s) from a given path based on the searched key string.
                return(this.ToCamelCase(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive, args.Data)));

            case "rename":
                // Renames a file or folder.
                return(this.ToCamelCase(this.operation.Rename(args.Path, args.Name, args.NewName, false, args.Data)));

            case "copy":
                // Copies the selected file(s) or folder(s) from a path and then pastes them into a given target path.
                return(this.ToCamelCase(this.operation.Copy(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData, args.Data)));

            case "move":
                // Cuts the selected file(s) or folder(s) from a path and then pastes them into a given target path.
                return(this.ToCamelCase(this.operation.Move(args.Path, args.TargetPath, args.Names, args.RenameFiles, args.TargetData, args.Data)));
            }
            return(null);
        }
示例#28
0
        // Uploads the file(s) to the files system.
        public virtual FileManagerResponse Upload(string path, IList <IFormFile> uploadFiles, string action, params FileManagerDirectoryContent[] data)
        {
            FileManagerResponse uploadResponse = new FileManagerResponse();

            try
            {
                string filename    = Path.GetFileName(uploadFiles[0].FileName);
                string contentType = uploadFiles[0].ContentType;
                int    idValue     = this.firebaseGetData.Select(x => x.Id).ToArray().Select(int.Parse).ToArray().Max();
                using (FileStream fsSource = new FileStream(Path.Combine(Path.GetTempPath(), filename), FileMode.Create))
                {
                    uploadFiles[0].CopyTo(fsSource);
                    fsSource.Close();
                }
                using (FileStream fsSource = new FileStream(Path.Combine(Path.GetTempPath(), filename), FileMode.Open, FileAccess.Read))
                {
                    BinaryReader br       = new BinaryReader(fsSource);
                    long         numBytes = new FileInfo(Path.Combine(Path.GetTempPath(), filename)).Length;
                    byte[]       bytes    = br.ReadBytes((int)numBytes);
                    this.GetRelativePath(data[0].Id, "/");
                    this.GetRelativeId(data[0].Id);
                    FileManagerDirectoryContent CreateData = new FileManagerDirectoryContent()
                    {
                        Id           = (idValue + 1).ToString(),
                        Name         = filename,
                        Size         = bytes.Length,
                        DateCreated  = DateTime.Now.ToString(),
                        DateModified = DateTime.Now.ToString(),
                        Type         = System.IO.Path.GetExtension(filename),
                        HasChild     = false,
                        ParentId     = data[0].Id,
                        IsFile       = true,
                        Content      = bytes,
                        isRoot       = (data[0].Id.ToString() == "0") ? true : false,
                        FilterPath   = this.filterPath.Substring(this.rootNode.Length) + "/",
                        FilterId     = this.filterId + "/"
                    };
                    this.updateDBNode(CreateData, idValue);
                }
            }
            catch (Exception e)
            {
                ErrorDetails er = new ErrorDetails();
                er.Message           = e.Message.ToString();
                uploadResponse.Error = er;
                return(uploadResponse);
            }
            return(uploadResponse);
        }
        public IActionResult GoogleDriveUpload(string path, IList <IFormFile> uploadFiles, string action, string data)
        {
            FileManagerResponse         uploadResponse;
            FileManagerDirectoryContent FileData = JsonConvert.DeserializeObject <FileManagerDirectoryContent>(data);

            uploadResponse = googleDrive.Upload(path, uploadFiles, action, FileData);
            if (uploadResponse.Error != null)
            {
                Response.Clear();
                Response.ContentType = "application/json; charset=utf-8";
                Response.StatusCode  = 204;
                Response.HttpContext.Features.Get <IHttpResponseFeature>().ReasonPhrase = uploadResponse.Error.Message;
            }
            return(Content(""));
        }
        public IActionResult Upload(string path, IList <IFormFile> uploadFiles, string action, string data)
        {
            FileManagerResponse uploadResponse;

            FileManagerDirectoryContent[] dataObject = new FileManagerDirectoryContent[1];
            dataObject[0]  = JsonConvert.DeserializeObject <FileManagerDirectoryContent>(data);
            uploadResponse = operation.Upload(path, uploadFiles, action, dataObject);
            if (uploadResponse.Error != null)
            {
                Response.Clear();
                Response.ContentType = "application/json; charset=utf-8";
                Response.StatusCode  = Convert.ToInt32(uploadResponse.Error.Code);
                Response.HttpContext.Features.Get <IHttpResponseFeature>().ReasonPhrase = uploadResponse.Error.Message;
            }
            return(Content(""));
        }