Pluggable file upload + storage (local or S3 via extras) module for simple_module apps
Project description
simple_module_file_storage
Pluggable file-upload + storage module for simple_module apps. Defaults to local-disk storage for development; install the [s3] extra to switch to any S3-compatible backend via aioboto3.
Install
# local-disk storage (dev default)
pip install simple_module_file_storage
# S3-compatible storage (production)
pip install "simple_module_file_storage[s3]"
What it provides
POST /api/file-storage/uploadmultipart upload endpoint.GET /api/file-storage/files(paged list),GET /api/file-storage/files/{file_id}(metadata),GET /api/file-storage/files/{file_id}/download(signed-URL redirect or stream),DELETE /api/file-storage/files/{file_id}.- Pluggable backend selected by the
backendsetting (filesystemdefault |s3); third-party backends can register under any id. - Settings (
backend,s3_bucket,s3_region,s3_endpoint_urlfor R2/MinIO/etc.,s3_access_key_id,s3_secret_access_key,s3_presign_ttl_seconds) are configured from the DB settings store via the admin UI — they are not read fromSM_FILE_STORAGE_*environment variables at runtime.
Usage
From another module, inject the service via its dependency:
from fastapi import Depends, File, UploadFile
from file_storage.deps import get_file_storage_service # type: ignore[import-not-found]
from file_storage.service import FileStorageService # type: ignore[import-not-found]
async def attach_receipt(
upload: UploadFile = File(...),
svc: FileStorageService = Depends(get_file_storage_service),
):
record = await svc.upload(upload)
return {"file_id": record.id}
Backend and S3 credentials are configured from the admin UI at /settings/modules → FileStorage (DB-backed settings); switch backend to s3 and fill in s3_bucket, s3_region, s3_endpoint_url (for MinIO/R2), s3_access_key_id, and s3_secret_access_key.
Depends on
simple_module_core,simple_module_db,simple_module_hosting,simple_module_settingsaiofiles- Optional:
aioboto3(install the[s3]extra)
License
MIT — see LICENSE.
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 simple_module_file_storage-0.0.20.tar.gz.
File metadata
- Download URL: simple_module_file_storage-0.0.20.tar.gz
- Upload date:
- Size: 24.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b4acf82ae855dbf2d8d4bcfcfd84c691376ece06622c246a42fa931e73ec45a
|
|
| MD5 |
cd5b85dec870a34dea6ab21407c3d1e4
|
|
| BLAKE2b-256 |
eed31be89e12fa3ac2b2cc9093eafdc428728ad5293d3d4d39cc6ef580e3a88c
|
Provenance
The following attestation bundles were made for simple_module_file_storage-0.0.20.tar.gz:
Publisher:
release.yml on antosubash/simple_module_python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_module_file_storage-0.0.20.tar.gz -
Subject digest:
1b4acf82ae855dbf2d8d4bcfcfd84c691376ece06622c246a42fa931e73ec45a - Sigstore transparency entry: 1908524606
- Sigstore integration time:
-
Permalink:
antosubash/simple_module_python@fef09599c696d641134ff17e3f2bd6bc5d5a14be -
Branch / Tag:
refs/heads/main - Owner: https://github.com/antosubash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fef09599c696d641134ff17e3f2bd6bc5d5a14be -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file simple_module_file_storage-0.0.20-py3-none-any.whl.
File metadata
- Download URL: simple_module_file_storage-0.0.20-py3-none-any.whl
- Upload date:
- Size: 28.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e83e8f2b786a876dff50b0e7c2d19538910de12ed9a1ac21e8d77c668a6485d
|
|
| MD5 |
a148b0d44d74884d2fd4c85b6665d59a
|
|
| BLAKE2b-256 |
98f04073bf726b12b29e132811e2aafa10b8e89f4b4ad64a59ad17131bd38d63
|
Provenance
The following attestation bundles were made for simple_module_file_storage-0.0.20-py3-none-any.whl:
Publisher:
release.yml on antosubash/simple_module_python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_module_file_storage-0.0.20-py3-none-any.whl -
Subject digest:
8e83e8f2b786a876dff50b0e7c2d19538910de12ed9a1ac21e8d77c668a6485d - Sigstore transparency entry: 1908524703
- Sigstore integration time:
-
Permalink:
antosubash/simple_module_python@fef09599c696d641134ff17e3f2bd6bc5d5a14be -
Branch / Tag:
refs/heads/main - Owner: https://github.com/antosubash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@fef09599c696d641134ff17e3f2bd6bc5d5a14be -
Trigger Event:
workflow_dispatch
-
Statement type: