https://github.com/xbsoftware/wfs
Web File System - core interface
https://github.com/xbsoftware/wfs
go webix wfs
Last synced: 5 months ago
JSON representation
Web File System - core interface
- Host: GitHub
- URL: https://github.com/xbsoftware/wfs
- Owner: xbsoftware
- License: mit
- Created: 2020-02-25T15:47:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-16T09:56:39.000Z (over 1 year ago)
- Last Synced: 2025-01-16T11:05:32.378Z (over 1 year ago)
- Topics: go, webix, wfs
- Language: Go
- Homepage: https://webix.com/filemanager
- Size: 18.6 KB
- Stars: 2
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Web File System - core interface
=========
File system abstraction with access management.
API provides common file operations for some folder on local drive. Any operations outside of the folder will be blocked. Also, it possible to configure a custom policy for read/write operations.
Can be used as backend for Webix File Manager https://webix.com/filemanager
## API
### Initialization
```go
import (
"github.com/xbsoftware/wfs-local"
)
fs, err := wfs.NewLocalDrive("./sandbox", nil)
```
### Get data
```go
//get files in a folder
files, err := fs.List("/subfolder");
//get files in a folder and subfolders as plain list
files, err = fs.List("/subfolder", &wfs.ListConfig{ SubFolders: true });
//get files in a folder and subfolders as nested structure
files, err = fs.List("/subfolder", &wfs.ListConfig{ SubFolders: true, Nested:true });
//get folder only
files, err = fs.List("/subfolder", &wfs.ListConfig{ SkipFiles: true });
//get files that match a mask
files, err = fs.List("/subfolder", &wfs.ListConfig{
Include: func(file string) bool { return strings.HasSufix(file, ".txt") },
});
//ignore some files
files, err = fs.List("/subfolder", &wfs.ListConfig{
Exclude: func(file string) bool { return file == ".git" },
});
//get info about a single file
info, err = fs.Info("some.txt");
//check if file exists
check := fs.Exists("some.txt");
```
### Modify files
```go
//make folder
fs.Make("/", "sub2", true);
//make file
fs.Make("/", "my.txt", false);
//remove
fs.Remove("some.txt");
//copy
fs.Copy("some.txt", "/sub/", "");
//copy as
fs.Copy("some.txt", "/sub/", "other.txt");
//move
fs.Move("some.txt", "/data/", "");
//rename
fs.Move("some.txt", "", "some-data.txt");
//read
reader, err := fs.Read("some.txt");
//write
fs.Write("some.txt", writer)
```
### Configuration
```go
// Access policies
// ForceRoot policy is added automatically
fs, err := wfs.NewLocalDrive("./sandbox", &wfs.DriveConfig{
Policy: &ReadOnlyPolicy{},
})
// Logging
fs, err := wfs.NewLocalDrive("./sandbox", &wfs.DriveConfig{
Verbose:true
})
// Exec operation with different config
path, err := fs.WithOperationConfig(&OperationConfig{
PreventNameCollision:true,
}).Make("/", "some", true)
```
### License
MIT