diff --git a/MANIFEST.in b/MANIFEST.in index bbb4b32..7c187d4 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ include LICENSE -include README.md +include README*.md include RELEASE-VERSION include version.py # recursive-include docs * diff --git a/README.md b/README.md index 9b3e1ed..e6b7253 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,24 @@ MINIO_POLICY_HOOKS: List[Tuple[str, dict]] = [] # MINIO_MEDIA_FILES_BUCKET = 'my-media-files-bucket' # replacement for MEDIA_ROOT # MINIO_STATIC_FILES_BUCKET = 'my-static-files-bucket' # replacement for STATIC_ROOT MINIO_BUCKET_CHECK_ON_SAVE = True # Default: True // Creates bucket if missing, then save + +# Custom HTTP Client (OPTIONAL) +import os +import certifi +import urllib3 +timeout = timedelta(minutes=5).seconds +ca_certs = os.environ.get('SSL_CERT_FILE') or certifi.where() +MINIO_HTTP_CLIENT: urllib3.poolmanager.PoolManager = urllib3.PoolManager( + timeout=urllib3.util.Timeout(connect=timeout, read=timeout), + maxsize=10, + cert_reqs='CERT_REQUIRED', + ca_certs=ca_certs, + retries=urllib3.Retry( + total=5, + backoff_factor=0.2, + status_forcelist=[500, 502, 503, 504] + ) +) ``` 4. Implement your own Attachment handler and integrate **django-minio-backend**: diff --git a/django_minio_backend/models.py b/django_minio_backend/models.py index a3cc080..abe4fe2 100644 --- a/django_minio_backend/models.py +++ b/django_minio_backend/models.py @@ -115,7 +115,9 @@ def __init__(self, raise ConfigurationError(f'The configured bucket ({self.bucket}) must be declared either in MINIO_PRIVATE_BUCKETS or MINIO_PUBLIC_BUCKETS') # https://docs.min.io/docs/python-client-api-reference.html - self.HTTP_CLIENT: urllib3.poolmanager.PoolManager = self._META_KWARGS.get("http_client", None) + http_client_from_kwargs = self._META_KWARGS.get("http_client", None) + http_client_from_settings = get_setting("MINIO_HTTP_CLIENT") + self.HTTP_CLIENT: urllib3.poolmanager.PoolManager = http_client_from_kwargs or http_client_from_settings bucket_name_intersection: List[str] = list(set(self.PRIVATE_BUCKETS) & set(self.PUBLIC_BUCKETS)) if bucket_name_intersection: