A file upload server of the tus resumable upload protocol is implemented on FastAPI framework.
Thanks to tusd, it provides great ideas and a sensible design pattern to implement Tus protocol to support multiple backend storage implementations.
Features:
- Basic operations to support Core Protocol such as HEAD, POST, PATCH, DELETE
- Creation With Upload
- Checksum such as md5
- Expiration
- Concatenation
- File storage
- S3 storage
Import TusRouter to your application,
from fastapi import FastAPI
from fastapi_tusd import TusRouter
app = FastAPI()
# `store_dir`: the folder to store uploaded files
# `location`: the API endpoint to serve, like `http://127.0.0.1:8000/files` or relative path `files` (TODO: induced from `prefix` in default)
app.include_router(TusRouter(store_dir="./files", location="/files"), prefix="/files")Then the tus upload endpoints will be served at http://127.0.0.1:8000/files, more information is available at http://127.0.0.1:8000/docs
There is a simple example with a web file upload client supporting for Tus protocol, thanks to Uppy!
Enter the example/ folder, and run(pip install uvicorn if no uvicorn!)
uvicorn app_tusd:app --reloadThen visit https://127.0.0.1:8000/upload.thml
GitHub - tus/tus-resumable-upload-protocol: Open Protocol for Resumable File Uploads