示例#1
0
        public FileManagerController()
        {
            // Map the path of the files to be accessed with the host
            var path = HostingEnvironment.MapPath("~/Content/images/FileManager");

            // Assign the mapped path as root folder
            operation.RootFolder(path);
        }
        public FileManagerController(IWebHostEnvironment hostingEnvironment)
        {
            hostingEnv = hostingEnvironment;
            var basePath = hostingEnvironment.ContentRootPath;

            operation = new PhysicalFileProvider();
            operation.RootFolder(basePath + "\\" + Root);
        }
示例#3
0
        public FilesApiController(FileManagerConfiguration fileManagerConfiguration,
                                  IPermissionVerificationService permissionVerificationService)
        {
            this.fileManagerConfiguration      = fileManagerConfiguration;
            this.permissionVerificationService = permissionVerificationService;

            operation = new PhysicalFileProvider();
            // Assign the mapped path as root folder
            operation.RootFolder(fileManagerConfiguration.StoragePath);
        }
示例#4
0
        public FileManagerResponse MoveToTrash(FileManagerDirectoryContent[] dataArray)
        {
            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>();
            PhysicalFileProvider trashOperation = new PhysicalFileProvider();
            string root = this.basePath + "\\wwwroot";

            trashOperation.RootFolder(root);
            List <FileManagerDirectoryContent> deletedFiles = new List <FileManagerDirectoryContent>();

            foreach (FileManagerDirectoryContent data in dataArray)
            {
                string   fileLocation = "/Files" + data.FilterPath;
                DateTime deleteTime   = DateTime.Now;
                string   container    = deleteTime.ToFileTimeUtc().ToString();
                string   trashPath    = "/Trash/" + container;
                Directory.CreateDirectory(root + trashPath);
                FileManagerResponse response = trashOperation.Move(fileLocation, trashPath, new string[] { data.Name }, null, null, null);
                if ((response.Error == null))
                {
                    TrashContents deletedFile = new TrashContents()
                    {
                        Container   = container,
                        Data        = data,
                        DateDeleted = deleteTime,
                        Name        = data.Name,
                        Path        = data.FilterPath
                    };
                    deletedFile.Data.DateModified = deletedFile.DateDeleted;
                    deletedFile.Data.Id           = deletedFile.Container;
                    DeletedFiles.Add(deletedFile);
                    deletedFiles.Add(response.Files.First());
                }
            }
            jsonData = JsonConvert.SerializeObject(DeletedFiles);
            System.IO.File.WriteAllText(jsonPath, jsonData);
            return(new FileManagerResponse()
            {
                Files = deletedFiles
            });
        }
 public FileMangerController(IHostingEnvironment hostingEnvironment)
 {
     basePath = hostingEnvironment.ContentRootPath;
     opration = new PhysicalFileProvider();
     opration.RootFolder(basePath + "\\" + this.root);
 }
示例#6
0
 public PreviewController(IWebHostEnvironment hostingEnvironment)
 {
     basePath  = hostingEnvironment.ContentRootPath;
     operation = new PhysicalFileProvider();
     operation.RootFolder(this.basePath + "\\wwwroot\\Files"); // Data\\Files denotes in which files and folders are available.
 }