Skip to content
/ restfs Public

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.

Notifications You must be signed in to change notification settings

purusha/restfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

restfs

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:

  1. oAuth
  2. basic authentication
  3. generate token from master password
  4. 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-HGF

    Response:

    {
        "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-HGF

    Response:

    {
        "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-HGF

    Response:

    {
        "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-HGF

    Response:

    {
        "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-HGF

    Response:

    {
    }
  • rename folder

    Request:
    PUT /dir/dir1?op=RENAME&target=dir2
    Authorization: XXX-YYY-ZZZ
    Accept: application/json
    X-Container: UUU-OOO-PPP-KKK-LLL-HGF

    Response:

    {
    }
  • delete file

    Request:
    DELETE /dir/email-reset42?op=DELETE
    Authorization: XXX-YYY-ZZZ
    Accept: application/json
    X-Container: UUU-OOO-PPP-KKK-LLL-HGF

    Response:

    {
    }
  • delete folder

    Request:
    DELETE /dir/to-be-deleted?op=DELETE
    Authorization: XXX-YYY-ZZZ
    Accept: application/json
    X-Container: UUU-OOO-PPP-KKK-LLL-HGF

    Response:

    {
    }
  • 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-HGF

    Response:

    {
    }
  • 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-HGF

    Response:

    {
    }
  • 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 file

    Response:

    {
        "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-HGF

    Response:

    {
        "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-HGF

    Response:

    {
    }
  • last N call (N configurable)

    Request:
    GET /latest
    Authorization: XXX-YYY-ZZZ
    Accept: application/json
    X-Container: UUU-OOO-PPP-KKK-LLL-HGF

    Response:

    {
    }
  • 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:

  1. git clone https://github.com/purusha/restfs.git
  2. cd restfs/backend
  3. mvn install
  4. 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)

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published