Skip to content

Commit 093546a

Browse files
committed
allow minio_kwargs to override values from settings
1 parent ea101ed commit 093546a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

minio_storage/storage.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,26 +364,25 @@ def get_setting(name: str, default=_NoValue) -> T.Any:
364364

365365

366366
def create_minio_client_from_settings(*, minio_kwargs=None):
367-
kwargs = {}
368367
endpoint = get_setting("MINIO_STORAGE_ENDPOINT")
369-
access_key = get_setting("MINIO_STORAGE_ACCESS_KEY")
370-
secret_key = get_setting("MINIO_STORAGE_SECRET_KEY")
371-
secure = get_setting("MINIO_STORAGE_USE_HTTPS", True)
368+
kwargs = {
369+
"access_key": get_setting("MINIO_STORAGE_ACCESS_KEY"),
370+
"secret_key": get_setting("MINIO_STORAGE_SECRET_KEY"),
371+
"secure": get_setting("MINIO_STORAGE_USE_HTTPS", True),
372+
}
372373
region = get_setting("MINIO_STORAGE_REGION", None)
373374
if region:
374375
kwargs["region"] = region
375376

376377
if minio_kwargs:
377378
kwargs.update(minio_kwargs)
379+
378380
# Making this client deconstructible allows it to be passed directly as
379381
# an argument to MinioStorage, since Django needs to be able to
380382
# deconstruct all Storage constructor arguments for Storages referenced in
381383
# migrations (e.g. when using a custom storage on a FileField).
382384
client = deconstructible(minio.Minio)(
383385
endpoint,
384-
access_key=access_key,
385-
secret_key=secret_key,
386-
secure=secure,
387386
**kwargs,
388387
)
389388
return client

0 commit comments

Comments
 (0)