Skip to main content

MinIO (S3-compatible) filesystem driver for the Masonite 5 framework

Project description

masonite-minio

A MinIO (S3-compatible) filesystem driver for the Masonite 5 framework. It extends Masonite's built-in S3 driver to target a custom MinIO endpoint with path-style addressing, and adds presigned URLs.

Install

pip install masonite-minio

Setup

1. Register the provider in config/providers.py:

from masonite_minio import MinioProvider

PROVIDERS = [
    # ... framework providers ...
    MinioProvider,
]

The driver is registered in the provider's register() phase, so placement is flexible — just keep MinioProvider after the framework's StorageProvider (appending it at the end of the list, as above, satisfies this).

2. Add a minio disk to the DISKS dict in config/filesystem.py:

from masonite.environment import env

DISKS = {
    # ... existing disks ...
    "minio": {
        "driver": "minio",
        "client": env("MINIO_CLIENT"),
        "secret": env("MINIO_SECRET"),
        "bucket": env("MINIO_BUCKET"),
        "endpoint": env("MINIO_ENDPOINT", "http://127.0.0.1:9000"),
        "region": env("MINIO_REGION", "us-east-1"),
    },
}

A copy of this block ships at masonite_minio/config/minio.py for reference. The driver reads options from DISKS, so the disk must be defined there — a standalone config file is not picked up automatically.

3. Set environment variables in .env:

MINIO_CLIENT=minioadmin
MINIO_SECRET=minioadmin
MINIO_BUCKET=my-bucket
MINIO_ENDPOINT=http://127.0.0.1:9000

# optional: make minio the default disk
FILESYSTEM_DISK=minio

Usage

from masonite.facades import Storage

Storage.disk("minio").put_file("avatars", uploaded_file)
contents = Storage.disk("minio").get("avatars/photo.png")
exists = Storage.disk("minio").exists("avatars/photo.png")

# presigned, time-limited URL (generated client-side)
url = Storage.disk("minio").get_secure_url("avatars/photo.png", expires=3600)

All standard Masonite filesystem operations are supported (put, put_file, get, exists, missing, stream, copy, move, delete, get_files, store), inherited from the framework's S3 driver.

Development

pip install -e ".[dev]"
ruff check . && ruff format --check .
pytest

Unit tests run offline. Integration tests against a live MinIO are skipped unless MINIO_TEST_ENDPOINT (+ MINIO_TEST_CLIENT/SECRET/BUCKET) are set:

docker run -p 9000:9000 -p 9001:9001 \
  -e MINIO_ROOT_USER=minioadmin -e MINIO_ROOT_PASSWORD=minioadmin \
  minio/minio server /data --console-address ":9001"

This publishes two ports: the S3 API on 9000 (use this for MINIO_ENDPOINT) and the web console on 9001 (http://127.0.0.1:9001, log in with minioadmin / minioadmin). Without --console-address, MinIO binds the console to a random internal port that isn't reachable from the host. A fresh server has no buckets — create MINIO_TEST_BUCKET from the console before running the integration tests.

License

MIT

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

masonite_minio-0.1.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

masonite_minio-0.1.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file masonite_minio-0.1.2.tar.gz.

File metadata

  • Download URL: masonite_minio-0.1.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for masonite_minio-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3203348e29c0bfc0fd7f2ad11a511c79afcbe075da25746d2c9d957d183245ed
MD5 c703449cb434a54241b7b6bb62b93699
BLAKE2b-256 fe449461a1f04b7f95680ea5bf5e33e2f9aea96a6b4537a03f4934f67463121f

See more details on using hashes here.

File details

Details for the file masonite_minio-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: masonite_minio-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for masonite_minio-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 72dceff2664559e0662a507b1554b803900c31b319138334b42e57a6407fe221
MD5 f16059b5953efb9fc29675cd458c5134
BLAKE2b-256 603217b634a6e5cf5fe3c9019f84f270c7faa1f940d623bba5f220cbe9a580e3

See more details on using hashes here.

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