https://github.com/nabijaczleweli/rfsapi-rs
Raw Filesystem API for Rust -- enable simpler browsing with ease
https://github.com/nabijaczleweli/rfsapi-rs
http-client http-server rfsapi rust web
Last synced: about 1 year ago
JSON representation
Raw Filesystem API for Rust -- enable simpler browsing with ease
- Host: GitHub
- URL: https://github.com/nabijaczleweli/rfsapi-rs
- Owner: nabijaczleweli
- License: mit
- Created: 2017-05-02T14:07:19.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-04-24T00:09:49.000Z (about 6 years ago)
- Last Synced: 2025-04-11T19:13:17.210Z (about 1 year ago)
- Topics: http-client, http-server, rfsapi, rust, web
- Language: Rust
- Size: 25.2 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# rfsapi-rs [](https://travis-ci.org/nabijaczleweli/rfsapi-rs) [](LICENSE) [](https://crates.io/crates/rfsapi-rs)
Raw Filesystem API for Rust — enable simpler browsing with ease
## [Documentation](https://rawcdn.githack.com/nabijaczleweli/rfsapi-rs/doc/rfsapi/index.html)
## Format brief
RFSAPI requests are made by setting a GET request's `X-Raw-Filesystem-API` header to `1`
If the server supports RFSAPI, the response will have its `X-Raw-Filesystem-API` header also set to `1`.
RFSAPI responses do *not* return file contents. Use an undecorated GET instead.
The response body is a JSON object of type [`FilesetData`](https://rawcdn.githack.com/nabijaczleweli/rfsapi-rs/doc/rfsapi/struct.FilesetData.html) in the following format:
```js
{
"writes_supported": boolean, // whether the server supports/allows write requests like PUT or DELETE
"is_root": boolean, // if this is a top-level directory
"is_file": boolean,
"files": Array
}
```
The [`RawFileData`](https://rawcdn.githack.com/nabijaczleweli/rfsapi-rs/doc/rfsapi/struct.RawFileData.html) objects describe each individual file in a listing:
```js
{
"mime_type": MIME type as string,
"name": string, // filename, no path
"last_modified": RFC3339 Date as string,
"size": integer,
"is_file": boolean
}
```
## Examples
Given the following tree at the root of the server (e.g. [`http`](https://crates.io/crates/https)), running on port 8000:
```plaintext
/
├── a.txt
├── ndis2-15.6.1.zip
└── works
└── b.txt
```
Then the metadata of a `curl -v -H "X-Raw-Filesystem-API: 1" 127.0.0.1:8000` invocation might look something like this:
```plaintext
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8000
> User-Agent: curl/7.64.0
> X-Raw-Filesystem-API: 1
>
< HTTP/1.1 200 OK
< Server: http/1.9.2
< X-Raw-Filesystem-API: 1
< Content-Type: application/json; charset=utf-8
< Content-Length: 843
< Date: Wed, 22 Apr 2020 17:46:51 GMT
<
* Connection #0 to host 127.0.0.1 left intact
```
Note:
* The server returned `X-Raw-Filesystem-API: 1`
* The server returned `Content-Type: application/json; charset=utf-8`
So we can be sure that the response body will be an RFSAPI `FilesetData`:
```json
{
"writes_supported": false,
"is_root": true,
"is_file": false,
"files": [
{
"mime_type": "application/zip",
"name": "ndis2-15.6.1.zip",
"last_modified": "2020-04-13T19:12:22.695457919Z",
"size": 31387,
"is_file": true
},
{
"mime_type": "text/directory",
"name": "works",
"last_modified": "2020-04-22T13:03:33.898025702Z",
"size": 0,
"is_file": false
},
{
"mime_type": "text/plain",
"name": "a.txt",
"last_modified": "2020-04-22T13:02:57.928406978Z",
"size": 7,
"is_file": true
}
]
}
```
Say we append some data to `a.txt`, or just want to check if it was modified;
`curl -H "X-Raw-Filesystem-API: 1" 127.0.0.1:8000/a.txt` might give us:
```json
{
"writes_supported": false,
"is_root": false,
"is_file": true,
"files": [
{
"mime_type": "text/plain",
"name": "a.txt",
"last_modified": "2020-04-22T17:55:18.159945230Z",
"size": 12,
"is_file": true
}
]
}
```
To see inside the `works` directory we can `curl -H "X-Raw-Filesystem-API: 1" 127.0.0.1:8000/works`:
```json
{
"writes_supported": false,
"is_root": false,
"is_file": false,
"files": [
{
"mime_type": "text/plain",
"name": "b.txt",
"last_modified": "2020-04-22T13:03:33.898026135Z",
"size": 13,
"is_file": true
}
]
}
```
## Special thanks
To all who support further development on Patreon, in particular:
* ThePhD