tuspyserver 2.2.0__tar.gz → 2.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tuspyserver-2.2.0/tuspyserver.egg-info → tuspyserver-2.2.1}/PKG-INFO +34 -4
- {tuspyserver-2.2.0 → tuspyserver-2.2.1}/README.md +33 -3
- {tuspyserver-2.2.0 → tuspyserver-2.2.1}/setup.py +1 -1
- {tuspyserver-2.2.0 → tuspyserver-2.2.1/tuspyserver.egg-info}/PKG-INFO +34 -4
- {tuspyserver-2.2.0 → tuspyserver-2.2.1}/tusserver/tus.py +11 -4
- {tuspyserver-2.2.0 → tuspyserver-2.2.1}/LICENSE +0 -0
- {tuspyserver-2.2.0 → tuspyserver-2.2.1}/setup.cfg +0 -0
- {tuspyserver-2.2.0 → tuspyserver-2.2.1}/tuspyserver.egg-info/SOURCES.txt +0 -0
- {tuspyserver-2.2.0 → tuspyserver-2.2.1}/tuspyserver.egg-info/dependency_links.txt +0 -0
- {tuspyserver-2.2.0 → tuspyserver-2.2.1}/tuspyserver.egg-info/requires.txt +0 -0
- {tuspyserver-2.2.0 → tuspyserver-2.2.1}/tuspyserver.egg-info/top_level.txt +0 -0
- {tuspyserver-2.2.0 → tuspyserver-2.2.1}/tusserver/__init__.py +0 -0
- {tuspyserver-2.2.0 → tuspyserver-2.2.1}/tusserver/metadata.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tuspyserver
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: TUS py protocol implementation in FastAPI
|
|
5
5
|
Home-page: https://github.com/edihasaj/tuspy-fast-api
|
|
6
6
|
Author: Edi Hasaj
|
|
@@ -50,8 +50,8 @@ pip install tuspyserver
|
|
|
50
50
|
Or install directly from source:
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
|
-
git clone https://github.com/
|
|
54
|
-
cd
|
|
53
|
+
git clone https://github.com/edihasaj/tuspy-fast-api
|
|
54
|
+
cd tuspy-fast-api
|
|
55
55
|
pip install .
|
|
56
56
|
```
|
|
57
57
|
|
|
@@ -74,6 +74,15 @@ app.add_middleware(
|
|
|
74
74
|
allow_origins=["*"],
|
|
75
75
|
allow_methods=["*"],
|
|
76
76
|
allow_headers=["*"],
|
|
77
|
+
expose_headers=[
|
|
78
|
+
"Location",
|
|
79
|
+
"Upload-Offset",
|
|
80
|
+
"Tus-Resumable",
|
|
81
|
+
"Tus-Version",
|
|
82
|
+
"Tus-Extension",
|
|
83
|
+
"Tus-Max-Size",
|
|
84
|
+
"Upload-Expires",
|
|
85
|
+
],
|
|
77
86
|
)
|
|
78
87
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|
|
79
88
|
|
|
@@ -91,6 +100,27 @@ app.include_router(
|
|
|
91
100
|
prefix="files", # OPTIONAL: URL prefix (default: 'files')
|
|
92
101
|
),
|
|
93
102
|
)
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### !Warning If you include your own router then it is necessary that your app allows these Headers:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
app.add_middleware(
|
|
110
|
+
CORSMiddleware, (# OPTIONAL: add CORS middleware if needed)
|
|
111
|
+
allow_origins=["*"], # OPTIONAL: allow all origins
|
|
112
|
+
allow_methods=["*"], # OPTIONAL: allow all methods
|
|
113
|
+
allow_headers=["*"], # OPTIONAL: allow all headers
|
|
114
|
+
expose_headers=[ # REQUIRED: expose these headers to the client
|
|
115
|
+
"Location",
|
|
116
|
+
"Upload-Offset",
|
|
117
|
+
"Tus-Resumable",
|
|
118
|
+
"Tus-Version",
|
|
119
|
+
"Tus-Extension",
|
|
120
|
+
"Tus-Max-Size",
|
|
121
|
+
"Upload-Expires",
|
|
122
|
+
],
|
|
123
|
+
)
|
|
94
124
|
```
|
|
95
125
|
|
|
96
126
|
### Dependency‑Injected Hook (Advanced)
|
|
@@ -161,6 +191,6 @@ scheduler.start()
|
|
|
161
191
|
|
|
162
192
|
## Contributing
|
|
163
193
|
|
|
164
|
-
Contributions welcome! Please open issues or PRs on [GitHub](https://github.com/
|
|
194
|
+
Contributions welcome! Please open issues or PRs on [GitHub](https://github.com/edihasaj/tuspy-fast-api).
|
|
165
195
|
|
|
166
196
|
*© 2025 Edi Hasaj [X](https://x.com/hasajedi)*
|
|
@@ -19,8 +19,8 @@ pip install tuspyserver
|
|
|
19
19
|
Or install directly from source:
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
git clone https://github.com/
|
|
23
|
-
cd
|
|
22
|
+
git clone https://github.com/edihasaj/tuspy-fast-api
|
|
23
|
+
cd tuspy-fast-api
|
|
24
24
|
pip install .
|
|
25
25
|
```
|
|
26
26
|
|
|
@@ -43,6 +43,15 @@ app.add_middleware(
|
|
|
43
43
|
allow_origins=["*"],
|
|
44
44
|
allow_methods=["*"],
|
|
45
45
|
allow_headers=["*"],
|
|
46
|
+
expose_headers=[
|
|
47
|
+
"Location",
|
|
48
|
+
"Upload-Offset",
|
|
49
|
+
"Tus-Resumable",
|
|
50
|
+
"Tus-Version",
|
|
51
|
+
"Tus-Extension",
|
|
52
|
+
"Tus-Max-Size",
|
|
53
|
+
"Upload-Expires",
|
|
54
|
+
],
|
|
46
55
|
)
|
|
47
56
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|
|
48
57
|
|
|
@@ -60,6 +69,27 @@ app.include_router(
|
|
|
60
69
|
prefix="files", # OPTIONAL: URL prefix (default: 'files')
|
|
61
70
|
),
|
|
62
71
|
)
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### !Warning If you include your own router then it is necessary that your app allows these Headers:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
app.add_middleware(
|
|
79
|
+
CORSMiddleware, (# OPTIONAL: add CORS middleware if needed)
|
|
80
|
+
allow_origins=["*"], # OPTIONAL: allow all origins
|
|
81
|
+
allow_methods=["*"], # OPTIONAL: allow all methods
|
|
82
|
+
allow_headers=["*"], # OPTIONAL: allow all headers
|
|
83
|
+
expose_headers=[ # REQUIRED: expose these headers to the client
|
|
84
|
+
"Location",
|
|
85
|
+
"Upload-Offset",
|
|
86
|
+
"Tus-Resumable",
|
|
87
|
+
"Tus-Version",
|
|
88
|
+
"Tus-Extension",
|
|
89
|
+
"Tus-Max-Size",
|
|
90
|
+
"Upload-Expires",
|
|
91
|
+
],
|
|
92
|
+
)
|
|
63
93
|
```
|
|
64
94
|
|
|
65
95
|
### Dependency‑Injected Hook (Advanced)
|
|
@@ -130,6 +160,6 @@ scheduler.start()
|
|
|
130
160
|
|
|
131
161
|
## Contributing
|
|
132
162
|
|
|
133
|
-
Contributions welcome! Please open issues or PRs on [GitHub](https://github.com/
|
|
163
|
+
Contributions welcome! Please open issues or PRs on [GitHub](https://github.com/edihasaj/tuspy-fast-api).
|
|
134
164
|
|
|
135
165
|
*© 2025 Edi Hasaj [X](https://x.com/hasajedi)*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tuspyserver
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: TUS py protocol implementation in FastAPI
|
|
5
5
|
Home-page: https://github.com/edihasaj/tuspy-fast-api
|
|
6
6
|
Author: Edi Hasaj
|
|
@@ -50,8 +50,8 @@ pip install tuspyserver
|
|
|
50
50
|
Or install directly from source:
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
|
-
git clone https://github.com/
|
|
54
|
-
cd
|
|
53
|
+
git clone https://github.com/edihasaj/tuspy-fast-api
|
|
54
|
+
cd tuspy-fast-api
|
|
55
55
|
pip install .
|
|
56
56
|
```
|
|
57
57
|
|
|
@@ -74,6 +74,15 @@ app.add_middleware(
|
|
|
74
74
|
allow_origins=["*"],
|
|
75
75
|
allow_methods=["*"],
|
|
76
76
|
allow_headers=["*"],
|
|
77
|
+
expose_headers=[
|
|
78
|
+
"Location",
|
|
79
|
+
"Upload-Offset",
|
|
80
|
+
"Tus-Resumable",
|
|
81
|
+
"Tus-Version",
|
|
82
|
+
"Tus-Extension",
|
|
83
|
+
"Tus-Max-Size",
|
|
84
|
+
"Upload-Expires",
|
|
85
|
+
],
|
|
77
86
|
)
|
|
78
87
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|
|
79
88
|
|
|
@@ -91,6 +100,27 @@ app.include_router(
|
|
|
91
100
|
prefix="files", # OPTIONAL: URL prefix (default: 'files')
|
|
92
101
|
),
|
|
93
102
|
)
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### !Warning If you include your own router then it is necessary that your app allows these Headers:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
app.add_middleware(
|
|
110
|
+
CORSMiddleware, (# OPTIONAL: add CORS middleware if needed)
|
|
111
|
+
allow_origins=["*"], # OPTIONAL: allow all origins
|
|
112
|
+
allow_methods=["*"], # OPTIONAL: allow all methods
|
|
113
|
+
allow_headers=["*"], # OPTIONAL: allow all headers
|
|
114
|
+
expose_headers=[ # REQUIRED: expose these headers to the client
|
|
115
|
+
"Location",
|
|
116
|
+
"Upload-Offset",
|
|
117
|
+
"Tus-Resumable",
|
|
118
|
+
"Tus-Version",
|
|
119
|
+
"Tus-Extension",
|
|
120
|
+
"Tus-Max-Size",
|
|
121
|
+
"Upload-Expires",
|
|
122
|
+
],
|
|
123
|
+
)
|
|
94
124
|
```
|
|
95
125
|
|
|
96
126
|
### Dependency‑Injected Hook (Advanced)
|
|
@@ -161,6 +191,6 @@ scheduler.start()
|
|
|
161
191
|
|
|
162
192
|
## Contributing
|
|
163
193
|
|
|
164
|
-
Contributions welcome! Please open issues or PRs on [GitHub](https://github.com/
|
|
194
|
+
Contributions welcome! Please open issues or PRs on [GitHub](https://github.com/edihasaj/tuspy-fast-api).
|
|
165
195
|
|
|
166
196
|
*© 2025 Edi Hasaj [X](https://x.com/hasajedi)*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import base64
|
|
2
|
+
import inspect
|
|
2
3
|
import json
|
|
3
4
|
import os
|
|
4
5
|
from datetime import datetime, timedelta
|
|
@@ -20,7 +21,7 @@ from starlette.responses import FileResponse
|
|
|
20
21
|
from tusserver.metadata import FileMetadata
|
|
21
22
|
|
|
22
23
|
|
|
23
|
-
def default_auth():
|
|
24
|
+
async def default_auth():
|
|
24
25
|
pass
|
|
25
26
|
|
|
26
27
|
|
|
@@ -107,7 +108,7 @@ def create_api_router(
|
|
|
107
108
|
return response
|
|
108
109
|
|
|
109
110
|
@router.patch("/{uuid}", status_code=status.HTTP_204_NO_CONTENT)
|
|
110
|
-
def upload_chunk(
|
|
111
|
+
async def upload_chunk(
|
|
111
112
|
response: Response,
|
|
112
113
|
uuid: str,
|
|
113
114
|
content_length: int = Header(None),
|
|
@@ -126,7 +127,10 @@ def create_api_router(
|
|
|
126
127
|
meta = _read_metadata(uuid)
|
|
127
128
|
if meta and meta.size == meta.offset:
|
|
128
129
|
file_path = os.path.join(files_dir, uuid)
|
|
129
|
-
on_complete(file_path, meta.metadata)
|
|
130
|
+
result = on_complete(file_path, meta.metadata)
|
|
131
|
+
# if the callback returned a coroutine, await it
|
|
132
|
+
if inspect.isawaitable(result):
|
|
133
|
+
await result
|
|
130
134
|
|
|
131
135
|
return headers
|
|
132
136
|
|
|
@@ -186,7 +190,10 @@ def create_api_router(
|
|
|
186
190
|
meta = _read_metadata(uuid)
|
|
187
191
|
if meta and meta.size == 0:
|
|
188
192
|
file_path = os.path.join(files_dir, uuid)
|
|
189
|
-
on_complete(file_path, meta.metadata)
|
|
193
|
+
result = on_complete(file_path, meta.metadata)
|
|
194
|
+
# if the callback returned a coroutine, await it
|
|
195
|
+
if inspect.isawaitable(result):
|
|
196
|
+
await result
|
|
190
197
|
|
|
191
198
|
return response
|
|
192
199
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|