aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: 9cdd0bea4a504698441b3674fda5acb02547a396 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# python-api-server


## Variables

``MAX_CONTENT_LENGTH``: maximal Filesize in MB; defaults to 5MB
``UPLOAD_DIRECTORY``: where to store the uploaded files; should be mapped to a volume; defaults to "/uploads"
``AUTH_TOKEN``: token used for authenticating

## ToDo

- [ ] wsgi server

## Example Docker-Compose

see [docker-compose.yml](./docker-compose.yml)

## API-Endpoints

### /list

#### input

```bash
curl -H "token: myuploadtoken" http://docker10.host.lan:5040/list | jq
```

#### output

```bash
{
  "files": [
    {
      "last_modified": "2023-04-13 11:43:51",
      "name": "file1",
      "size": 1034
    },
    {
      "last_modified": "2023-04-13 11:53:59",
      "name": "file2",
      "size": 5
    },
    {
      "last_modified": "2023-04-13 12:41:18",
      "name": "file3",
      "size": 3478
    }
  ]
}
```

### /upload

If a file is uploaded with the same name as an existing file, it will be overwritten.

#### input

```bash
curl -X POST -H "token: myuploadtoken" -F "file=@tests/file" http://docker10.host.lan:5040/upload | jq
```

#### output

```bash
{
  "success": "File 'file' successfully uploaded"
}
```

### /download

#### input

```bash
wget http://docker10.host.lan:5040/download/file
```

### /delete

#### input

```bash
curl -X DELETE -H "token: myuploadtoken" http://docker10.host.lan:5040/delete/file | jq
```

#### output

```bash
{
  "success": "File 'file' successfully deleted"
}
```