Skip to content

Commit

Permalink
allow minio_kwargs to override values from settings
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasf committed Jun 8, 2023
1 parent ea101ed commit 093546a
Showing 1 changed file with 6 additions and 7 deletions.
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

0 comments on commit 093546a

Please sign in to comment.