Restfs exposes your file system as a rest api. Is not a static file server, but instead lets you browse stats, and manipulate files through arbitrary paths.
It is possible to manage multiple containers (multi tenant), each with its own "virtual" file system.
For this reason the X-Container header is mandatory in every single request.
Each container has its own method for authenticating requests; the available methods are:
- oAuth
- basic authentication
- generate token from master password
- no auth
Available operation on container:
-
create folder (any path)
Request:
POST /dir/dir1/dir2?op=MKDIRS
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGFResponse:
{ "children":[ ], "created":"2019-01-29@17:05:54", "lastAccess":"2019-01-29@17:05:54", "length":0, "modified":"2019-01-29@17:05:54", "name":"dir2", "type":"FOLDER" }
-
create file (folder must exist)
Request:
POST /dir/user42?op=CREATE
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGFResponse:
{ "created":"2019-01-29@17:05:54", "lastAccess":"2019-01-29@17:05:54", "length":0, "modified":"2019-01-29@17:05:54", "name":"user42", "type":"FILE" }
-
get file attributes
Request:
GET /dir/user42?op=GETSTATUS
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGFResponse:
{ "created":"2019-01-29@17:05:54", "lastAccess":"2019-01-29@17:05:54", "length":0, "modified":"2019-01-29@17:05:54", "name":"user42", "type":"FILE" }
-
get folder attributes
Request:
GET /dir/dir1?op=LISTSTATUS
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGFResponse:
{ "children":[ ], "created":"2019-01-29@17:05:54", "lastAccess":"2019-01-29@17:05:54", "length":0, "modified":"2019-01-29@17:05:54", "name":"dir1", "type":"FOLDER" }
-
rename file
Request:
PUT /dir/dir2/user42?op=RENAME&target=user42
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGFResponse:
{ }
-
rename folder
Request:
PUT /dir/dir1?op=RENAME&target=dir2
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGFResponse:
{ }
-
delete file
Request:
DELETE /dir/email-reset42?op=DELETE
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGFResponse:
{ }
-
delete folder
Request:
DELETE /dir/to-be-deleted?op=DELETE
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGFResponse:
{ }
-
move file in any existing path
Request:
PUT /dir/dir2/user42?op=MOVE&target=dir/dir2
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGFResponse:
{ }
-
move folderX in any existing folder
Request:
PUT /dir/dir2/dir3/dir4?op=MOVE&target=dir/dir2
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGFResponse:
{ }
-
append text on existing file (text or gzip)
Request:
POST /dir/user42?op=APPEND
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGF
Content-Encoding: gzip OR identity (based on what add into the body)
BODY content is what will be saved into the fileResponse:
{ "created":"2019-01-29@17:05:54", "lastAccess":"2019-01-29@17:05:54", "length":108, "modified":"2019-01-29@17:05:54", "name":"user42", "type":"FILE" }
-
retrieve file
Request:
GET /dir/user42?op=OPEN
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGFResponse:
{ "content":[ "first line", "second line", "afsidbfasbdflasbdfljasdf asdfuasd fuas ydfasd fasudfyvasdf", "last line" ], "path":"/dir/file5" }
Management operation on container:
-
stats
Request:
GET /stats
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGFResponse:
{ }
-
last N call (N configurable)
Request:
GET /latest
Authorization: XXX-YYY-ZZZ
Accept: application/json
X-Container: UUU-OOO-PPP-KKK-LLL-HGFResponse:
{ }
-
webhook (configurable for flush data on expired time or number of events)
This is project is under develop ... see todo file to discover new functionality todo file
It is possible to build the project independently and run it on any machine;
steps are:
- git clone https://github.com/purusha/restfs.git
- cd restfs/backend
- mvn install
- java -jar target/restfs-[VERSION].jar
Restfs expose two ports: the first public http://localhost:8081 (to be used with an HTTP client); the second for administration purpose http://localhost:8086/containers (to be used with a browser)