Skip to content

Commit d37c8fb

Browse files
committed
feat: readme.md
1 parent f42525e commit d37c8fb

5 files changed

Lines changed: 38 additions & 22 deletions

File tree

README.md

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# fileserver
22

3-
The `fileserver` can be used as a static file server to share your file to people and also can as a private file server to upload and download your private files.
3+
The `fileserver` can be used as a static file server to share your file and also can as a private file server to upload and download your private files.
44

55
## Features
66
- Directory index
@@ -11,27 +11,43 @@ The `fileserver` can be used as a static file server to share your file to peopl
1111
- JSON API
1212

1313
## Usage
14-
### API
15-
1. Execute the following command will upload the `img.png` to the `image` directory on the file server and produces a file named `img.png`. If the `image` directory does not exist, it will be created.
16-
```bash
17-
$ curl -T img.png http://localhost:8880/image/
18-
$ # or
19-
$ curl -F 'file=@img.png' http://localhost:8880/image/
20-
```
21-
22-
2. Execute the following command will upload the `img.png` to the `image` directory on the file server and produces a file named `another.png`. If the `image` directory does not exist, it will be created.
23-
```bash
24-
$ curl -T img.png http://localhost:8880/image/another.png
25-
$ # or
26-
$ curl -F 'file=@img.png' http://localhost:8880/image/another.png
27-
```
28-
29-
### Web UI
30-
**Index**
31-
> ![Index](img/index.png)
32-
33-
**Upload**
34-
> ![Upload](img/upload.png)
14+
### API usage
15+
**File upload - Using default file name**
16+
17+
Following command will upload the `img.png` to the directory `/image/a/b/c/` on the file server and produces a file named `img.png`.
18+
```bash
19+
$ curl -T img.png http://localhost:8880/image/a/b/c/
20+
$ # or
21+
$ curl -F 'file=@img.png' http://localhost:8880/image/a/b/c/
22+
```
23+
24+
**File upload - Specify file name**
25+
26+
Following command will upload the `img.png` to the directory `/image/a/b/c/` on the file server and produces a file named `another.png`.
27+
```bash
28+
$ curl -T img.png http://localhost:8880/image/a/b/c/another.png
29+
$ # or
30+
$ curl -F 'file=@img.png' http://localhost:8880/image/a/b/c/another.png
31+
```
32+
33+
> Note:
34+
> 1. If the specified directory does not exist on the file server, this directory will be created first.
35+
> 2. If the file to be uploaded already exists on the file server, the file will be overwritten.
36+
37+
**File download**
38+
```bash
39+
$ curl http://localhost:8880/image/a/b/c/another.png
40+
```
41+
42+
### UI usage
43+
**Directory index**
44+
45+
The directory index access URL is the same as the API's access URL(Such as `http://localhost:8880/image/a/b/c/`). Just type the URL in the browser, and you'll see what's inside.
46+
47+
> ![Index](_img/index.png)
48+
49+
**File upload**
50+
> ![Upload](_img/upload.png)
3551
3652
## Build
3753
```bash

_img/index.png

32.7 KB
Loading

_img/upload.png

31.7 KB
Loading

img/index.png

-84.2 KB
Binary file not shown.

img/upload.png

-46.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)