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

Let user specify a HTTP proxy and region #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions minio_storage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import posixpath
import typing as T
import urllib
import urllib3
from logging import getLogger
from time import mktime
from urllib.parse import urlsplit, urlunsplit
Expand Down Expand Up @@ -365,6 +366,20 @@ def create_minio_client_from_settings(*, minio_kwargs=dict()):
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", 'us-east-1')
# Eventually handle the need for a HTTP proxy
http_client = None
if get_setting("MINIO_STORAGE_HTTP_PROXY"):
http_client = urllib3.ProxyManager(
get_setting("MINIO_STORAGE_HTTP_PROXY"),
timeout=urllib3.Timeout.DEFAULT_TIMEOUT,
retries=urllib3.Retry(
total=5,
backoff_factor=0.2,
status_forcelist=[500, 502, 503, 504],
)
)

# 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
Expand All @@ -374,6 +389,8 @@ def create_minio_client_from_settings(*, minio_kwargs=dict()):
access_key=access_key,
secret_key=secret_key,
secure=secure,
region=region,
http_client=http_client,
**minio_kwargs,
)
return client
Expand Down