FastAPI integration for the MFUP/2 upload engine: MfupEngine + APIRouter you mount into your own app, or a ready-to-run standalone server.
Project description
mfup-fastapi
FastAPI integration for the MFUP/2 resumable multi-file upload engine
(mfup-core).
Embed into your app
from pathlib import Path
from fastapi import FastAPI
from mfup_fastapi import MfupConfig, MfupEngine
from mfup_core import AuthRequest, AuthResult
async def authorize(req: AuthRequest) -> AuthResult | None:
user = await my_auth(req.headers) # cookies / Authorization
if user is None:
return None # → SESSION_ABORT(auth_failed)
return AuthResult(
base_dir=f"/srv/homes/{user.id}", # per-user home
max_total_bytes=10 * 2**30, # 10 GiB quota
context={"user_id": user.id},
)
engine = MfupEngine(MfupConfig(
base_dir=Path("/srv/uploads"),
redis_url="redis://localhost:6379/0",
authorize=authorize, # a callable — or "pkg.mod:func"
))
app = FastAPI(lifespan=engine.lifespan)
app.include_router(engine.router, prefix="/api/uploads")
Point the browser SDK (@mfup/client on npm) at the same prefix:
new MfupSession({ serverUrl: "https://host/api/uploads" }).
Run standalone
pip install mfup-fastapi
MFUP_BASE_DIR=/srv/uploads REDIS_URL=redis://localhost:6379/0 \
python -m mfup_fastapi
All MfupConfig fields map 1:1 to MFUP_* environment variables
(MfupConfig.from_env()); hooks are dotted paths there
(MFUP_AUTHORIZE=myapp.uploads:authorize).
Hooks
| Hook | When | Controls |
|---|---|---|
authorize |
HELLO, before anything is created | allow/deny, per-user base_dir, target mapping, byte/file quotas, context |
map_file |
publish, per file | final layout (by type/scope/anything) |
on_committed |
after COMMIT_OK | notification; return "publish" to publish server-side (scan/moderation/billing flows). Or call engine.publish(session_id) yourself later. |
Requires Redis (expiry index) and a POSIX filesystem. One worker per engine
instance; resume across workers is handled via lazy recovery from the Redis
index. Full contract: docs/EXTENDING.md in the repository.
Docs and source: https://github.com/n0isy/mfup
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mfup_fastapi-0.2.0.tar.gz.
File metadata
- Download URL: mfup_fastapi-0.2.0.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1401aac4b230d8186a437871d292872650c55504d90e7a0164fc209f1c91df1b
|
|
| MD5 |
205bb0537dba251afab28845dfd6c786
|
|
| BLAKE2b-256 |
2c05432f440583ae5f99896ede5c5e4512c7de44ea05a5a969103c83c9cd6b84
|
Provenance
The following attestation bundles were made for mfup_fastapi-0.2.0.tar.gz:
Publisher:
release.yml on n0isy/mfup
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mfup_fastapi-0.2.0.tar.gz -
Subject digest:
1401aac4b230d8186a437871d292872650c55504d90e7a0164fc209f1c91df1b - Sigstore transparency entry: 2340952596
- Sigstore integration time:
-
Permalink:
n0isy/mfup@6e337f11adaa9c0c6428eee0808107cafe747dd0 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/n0isy
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6e337f11adaa9c0c6428eee0808107cafe747dd0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mfup_fastapi-0.2.0-py3-none-any.whl.
File metadata
- Download URL: mfup_fastapi-0.2.0-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73a199dc31c9d898871dc09c190b51120f6db77b127521f0619fae70e76f2908
|
|
| MD5 |
f4a2f75998ea686ca686ef9b43c72f4c
|
|
| BLAKE2b-256 |
4579a331434b9514f0dc1dff858bdd45f60645f38d8f855968796e751423740b
|
Provenance
The following attestation bundles were made for mfup_fastapi-0.2.0-py3-none-any.whl:
Publisher:
release.yml on n0isy/mfup
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mfup_fastapi-0.2.0-py3-none-any.whl -
Subject digest:
73a199dc31c9d898871dc09c190b51120f6db77b127521f0619fae70e76f2908 - Sigstore transparency entry: 2340952612
- Sigstore integration time:
-
Permalink:
n0isy/mfup@6e337f11adaa9c0c6428eee0808107cafe747dd0 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/n0isy
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6e337f11adaa9c0c6428eee0808107cafe747dd0 -
Trigger Event:
push
-
Statement type: