Skip to main content

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/files upload endpoint with multipart + metadata.
  • GET /api/files/{id} signed-URL or stream download.
  • Pluggable backend via SM_FILE_STORAGE_BACKEND (local | s3).
  • S3 config via SM_FILE_STORAGE_S3_BUCKET, SM_FILE_STORAGE_S3_ENDPOINT (for R2/MinIO/etc.), SM_FILE_STORAGE_S3_REGION.

Usage

From another module:

from file_storage.service import FileStorageService   # type: ignore[import-not-found]

async def attach_receipt(
    svc: FileStorageService = Depends(FileStorageService),
    upload: UploadFile = File(...),
):
    record = await svc.save(upload, folder="receipts/")
    return {"file_id": record.id, "url": record.url}

Env config (example, S3):

SM_FILE_STORAGE_BACKEND=s3
SM_FILE_STORAGE_S3_BUCKET=my-app-uploads
SM_FILE_STORAGE_S3_REGION=us-east-1
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...

Depends on

  • simple_module_core, simple_module_db, simple_module_hosting
  • aiofiles
  • Optional: aioboto3 (install the [s3] extra)

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_module_file_storage-0.0.2.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_module_file_storage-0.0.2-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file simple_module_file_storage-0.0.2.tar.gz.

File metadata

File hashes

Hashes for simple_module_file_storage-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b2584c04756e8670a8fab4e0c0dd0e287104db2b03ded0f3d20c93d0ba3ead1a
MD5 da41bb400dfe3126eae05f032a7047b5
BLAKE2b-256 08503a949e4d5b2573de146fc18d36c83bc21e6f7db2705f8549e898a68af657

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_file_storage-0.0.2.tar.gz:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simple_module_file_storage-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_module_file_storage-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 49ed86ae9c9364e55bf8c57b6ad82e810d91d5a1a28db577358f1c680b0a693f
MD5 0264d1b9e5ba6c54f7c46e08328d4fc4
BLAKE2b-256 1b28f2e8919fabbdd19038f4a19c063c2f0702d65d8900541362e4286a312ace

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_file_storage-0.0.2-py3-none-any.whl:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page