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,
]

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.0.tar.gz (5.3 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.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: masonite_minio-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 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.0.tar.gz
Algorithm Hash digest
SHA256 8282fad17f07fc770b8a5477d6f279e299170423abf65a303993c2212a05e02f
MD5 bbf4f392541d65fc2a6ff79693290ab4
BLAKE2b-256 33c5dd6a683da06d64af1c2b705e1f200c1da44c9f6fb18a2558f2eaac6b39b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: masonite_minio-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 debd8252487ea8e80c43bb1a90108b8d198033a969e056b56e7d388643425f95
MD5 d9013147af8f7a4305ca9fb5aa388583
BLAKE2b-256 7ddf377701306b638b8420f0dcee5c085cad1f830fc311866ea7361987869dbc

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