@@ -7,6 +7,7 @@ The `fileserver` can be used as a static file server to share your file and also
77- File download
88- File upload (batch upload supported)
99- Directory creation
10+ - File/directory deletion (opt-in via ` -allow-delete ` )
1011- HTTPS supported
1112- Basic Auth
1213- Web UI
@@ -20,14 +21,20 @@ The `fileserver` can be used as a static file server to share your file and also
2021# Basic usage
2122./fileserver -port 8880 -basedir /path/to/files
2223
23- # With basic auth
24- ./fileserver -port 8880 -basedir /path/to/files -user admin -pass secret
24+ # With Basic Auth (default: only uploads / mkdir / delete need credentials; browsing is public)
25+ ./fileserver -port 8880 -basedir /path/to/files -auth " admin:secret"
26+
27+ # Require Basic Auth for every request (including reads)
28+ ./fileserver -port 8880 -basedir /path/to/files -auth " admin:secret" -auth-scope all
2529
2630# With TLS
2731./fileserver -port 8443 -basedir /path/to/files -tls-cert cert.pem -tls-key key.pem
2832
29- # With TLS and basic auth
30- ./fileserver -port 8443 -basedir /path/to/files -tls-cert cert.pem -tls-key key.pem -user admin -pass secret
33+ # With TLS and Basic Auth
34+ ./fileserver -port 8443 -basedir /path/to/files -tls-cert cert.pem -tls-key key.pem -auth " admin:secret"
35+
36+ # Enable deletion
37+ ./fileserver -port 8880 -basedir /path/to/files -allow-delete
3138```
3239
3340#### Flags
@@ -38,14 +45,13 @@ The `fileserver` can be used as a static file server to share your file and also
3845| ` -basedir ` | ` . ` | Which directory to serve |
3946| ` -tls-cert ` | ` "" ` | TLS cert file location |
4047| ` -tls-key ` | ` "" ` | TLS key file location |
41- | ` -user ` | ` "" ` | Basic auth username |
42- | ` -pass ` | ` "" ` | Basic auth password |
43-
44- > When ` -user ` and ` -pass ` are both set, all requests (WebUI and API) require HTTP Basic Authentication.
48+ | ` -auth ` | ` "" ` | Basic auth as ` username:password ` (password may contain ` : ` ). Empty disables Basic auth |
49+ | ` -auth-scope ` | ` write ` | With ` -auth ` : ` write ` = only POST/PUT/PATCH/DELETE need auth; ` all ` = every request needs auth |
50+ | ` -allow-delete ` | ` false ` | Enable file/directory deletion |
4551
4652### API usage
4753
48- When basic auth is enabled, add ` -u user:pass ` to all curl commands .
54+ When Basic Auth is enabled, add ` -u user:pass ` to curl for requests that require credentials. With the default ` -auth-scope write ` , ** GET/HEAD ** (download, JSON listing) are usually anonymous; ** POST ** (upload, mkdir), ** PUT ** , and ** DELETE ** need ` -u ` . With ` -auth-scope all` , add ` -u ` to every request .
4955
5056** File upload - Using default file name**
5157
@@ -55,7 +61,7 @@ Following command will upload the `img.png` to the directory `/image/a/b/c/` on
5561 $ # or
5662 $ curl -F ' file=@img.png' http://localhost:8880/image/a/b/c/
5763
58- # With basic auth
64+ # With Basic Auth (upload is a write)
5965 $ curl -u admin:secret -T img.png http://localhost:8880/image/a/b/c/
6066 ```
6167
@@ -76,24 +82,33 @@ Following command will upload the `img.png` to the directory `/image/a/b/c/` on
7682``` bash
7783$ curl -X POST ' http://localhost:8880/path/to/?action=mkdir&name=new-folder'
7884
79- # With basic auth
85+ # With Basic Auth
8086$ curl -u admin:secret -X POST ' http://localhost:8880/path/to/?action=mkdir&name=new-folder'
8187```
8288
8389** File download**
8490``` bash
8591$ curl http://localhost:8880/image/a/b/c/another.png
8692
87- # With basic auth
88- $ curl -u admin:secret http://localhost:8880/image/a/b/c/another.png
93+ # Only needed if `-auth-scope all`; with default `write`, download is anonymous
94+ $ curl http://localhost:8880/image/a/b/c/another.png
95+ ```
96+
97+ ** Delete file or directory** (requires ` -allow-delete ` ; with Basic Auth, DELETE is a write — add ` -u ` when ` -auth ` is set)
98+ ``` bash
99+ # Delete a file
100+ $ curl -u admin:secret -X DELETE http://localhost:8880/path/to/file.txt
101+
102+ # Delete a directory (recursively)
103+ $ curl -u admin:secret -X DELETE http://localhost:8880/path/to/dir/
89104```
90105
91106** List directory (JSON)**
92107``` bash
93108$ curl http://localhost:8880/path/to/dir/
94109
95- # With basic auth
96- $ curl -u admin:secret http://localhost:8880/path/to/dir/
110+ # Only needed if `- auth-scope all`; with default `write`, JSON listing is anonymous
111+ $ curl http://localhost:8880/path/to/dir/
97112```
98113
99114### UI usage
0 commit comments