Skip to content

Commit

Permalink
Add configurations to allow boto to connect to minio
Browse files Browse the repository at this point in the history
  • Loading branch information
nearlynocturnalbeach committed Aug 19, 2023
1 parent c848adc commit c6f3fec
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions NearBeach/views/document_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,20 @@ def __init__(self, settings):
"aws_access_key_id": settings.AWS_ACCESS_KEY_ID,
"aws_secret_access_key": settings.AWS_SECRET_ACCESS_KEY,
}
if getattr(settings, "AWS_S3_ENDPOINT_URL", None):
# Assume the person is using minio so defualts are the values
# which will allow for connection to minio
botoInitValues.update(
aws_endpoint_url=settings.AWS_S3_ENDPOINT_URL,
aws_session_token=getattr(settings, "AWS_S3_SESSION_TOKEN", None),
config=getattr(
settings,
"AWS_CONFIG",
boto3.session.Config(signature_version='s3v4'),
),
verify=getattr(settings, "AWS_VERIFY_TLS", True),
**getattr(settings, "AWS_INIT_VALUES", {})
)
self._s3 = boto3.client("s3", **botoInitValues)
self._bucket = settings.AWS_STORAGE_BUCKET_NAME

Expand Down
8 changes: 8 additions & 0 deletions local/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@
AWS_LOCATION = F"{VERSION}"
AWS_S3_ENDPOINT_URL = F"https://{CLOUDFLARE_ACCOUNT_ID}.r2.cloudflarestorage.com"

# To use a selfsigned cert you can put the path to the cert bundle
# here e.g. AWS_VERIFY_TLS = path/to/cert/bundle.pem
# AWS_VERIFY_TLS = False

# AWS_CONFIG can be used to set configure the botocore config
# see https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html


# Defining STORAGES
STORAGES = {"staticfiles": {"BACKEND": "storages.backends.s3boto3.S3StaticStorage"}}

Expand Down

0 comments on commit c6f3fec

Please sign in to comment.