Protected files for Karni: files a row owns, in S3 or an S3-compatible service, served only to whoever may read that row, with direct uploads and thumbnails. Karni is an open-source Django + React framework for building with AI coding agents. Your agent writes only your domain. The API, admin, permissions and React screens come from a package you upgrade, not code it rewrites in each project. One rule set covers every coding agent. The build fails when an agent hand-writes what Karni ships.
pip install karni-storage Copy PIP instructions
Files are kept in S3 or an S3-compatible service (or on disk in development) and handed only to whoever may read their row. It is experimental: its names may change in a minor release, with a CHANGELOG entry.
pip install "karni-storage[images]" # the images extra brings Pillow, for thumbnails karni add storage Then add the URLs once to config/urls.py:
path("api/", include("karni_storage.urls")), and run make migrate (the module has one table, its thumbnails).
from karni_storage.fields import ProtectedFileField, ProtectedImageField class Product(BaseModel): manual = ProtectedFileField(upload_to="products/manuals/", blank=True, max_size=5 * 1024 * 1024, content_types=["application/pdf"]) photo = ProtectedImageField(upload_to="products/photos/", blank=True) In karni.yaml the same fields are manual: "file:protected?" and photo: "image:protected?".
The API gives manual as /api/products/ /files/manual/. A GET there retrieves the row through ProductViewSet first: 401 or 403 from its gate, 404 for another user's row, a soft-deleted row or a missing one. Then it redirects to a signed URL in the bucket (KARNI_STORAGE=s3) or streams the file (KARNI_STORAGE=local). ?size=small serves a thumbnail of an image.
Credentials stay in the environment: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_STORAGE_BUCKET_NAME, AWS_S3_REGION_NAME and, for R2, R2_ACCOUNT_ID. karni check fails (STORE001 to STORE006) on an unknown preset, missing credentials, a missing region, account id, endpoint or bucket, and a missing URL include.
No admin.py: the thumbnails' admin is derived from AdminMeta.
django karni minio r2 react s3 storage uploads
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




