Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow minio_kwargs to override values from settings #131

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions minio_storage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,26 +364,25 @@ def get_setting(name: str, default=_NoValue) -> T.Any:


def create_minio_client_from_settings(*, minio_kwargs=None):
kwargs = {}
endpoint = get_setting("MINIO_STORAGE_ENDPOINT")
access_key = get_setting("MINIO_STORAGE_ACCESS_KEY")
secret_key = get_setting("MINIO_STORAGE_SECRET_KEY")
secure = get_setting("MINIO_STORAGE_USE_HTTPS", True)
kwargs = {
"access_key": get_setting("MINIO_STORAGE_ACCESS_KEY"),
"secret_key": get_setting("MINIO_STORAGE_SECRET_KEY"),
"secure": get_setting("MINIO_STORAGE_USE_HTTPS", True),
}
region = get_setting("MINIO_STORAGE_REGION", None)
if region:
kwargs["region"] = region

if minio_kwargs:
kwargs.update(minio_kwargs)

# Making this client deconstructible allows it to be passed directly as
# an argument to MinioStorage, since Django needs to be able to
# deconstruct all Storage constructor arguments for Storages referenced in
# migrations (e.g. when using a custom storage on a FileField).
client = deconstructible(minio.Minio)(
endpoint,
access_key=access_key,
secret_key=secret_key,
secure=secure,
**kwargs,
)
return client
Expand Down