Skip to content
Yubaraj Shrestha edited this page Dec 30, 2021 · 1 revision

Welcome to the minio-masonite-driver wiki!

What is Minio-Driver?

It's an extra storage driver support for Minio in masonite 4.

Setup

Install package using pip:

pip install minio-driver

Add provider inside config/providers.py.

from minio_driver.MinioProvider import MinioProvider

PROVIDERS = [
    ...,
    # Application Providers
    MinioProvider,
]

Storage Config

Add following configuration inside config/filesystem.py after "s3": {...},

"minio": {
    "driver": "minio",
    "client": env("MINIO_CLIENT"),
    "secret": env("MINIO_SECRET"),
    "bucket": env("MINIO_BUCKET"),
    "path": env("MINIO_ENDPOINT"),
},

Add following keys in .env.

MINIO_CLIENT=
MINIO_SECRET=
MINIO_BUCKET=
MINIO_ENDPOINT=

Example

from masonite.controllers import Controller
from masonite.filesystem import Storage
from masonite.request import Request

class YourController(Controller):

    def your_function(self, request: Request, storage: Storage):
        file = request.input('file')
        path = storage.disk("minio").put_file('your_file_directory', file)
        return path

Enjoy ;)

Clone this wiki locally