Skip to content

Commit

Permalink
Set default Region and generate public_url from minio
Browse files Browse the repository at this point in the history
The default Region is set to us-east-1
the public URL generated for AWS specific resources is diferent than
minio specific servers. Still, minio SDK has a special reference to
figure out how to generate URLs if AWS is used in the backend.
  • Loading branch information
subho007 committed Feb 3, 2023
1 parent fcaea67 commit b1f32ca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions django_minio_backend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self,
self.__MINIO_ACCESS_KEY: str = get_setting("MINIO_ACCESS_KEY")
self.__MINIO_SECRET_KEY: str = get_setting("MINIO_SECRET_KEY")
self.__MINIO_USE_HTTPS: bool = get_setting("MINIO_USE_HTTPS")
self.__MINIO_REGION: str = get_setting("MINIO_REGION", None)
self.__MINIO_REGION: str = get_setting("MINIO_REGION", "us-east-1") # MINIO defaults to "us-east-1" when region is set to None
self.__MINIO_EXTERNAL_ENDPOINT_USE_HTTPS: bool = get_setting("MINIO_EXTERNAL_ENDPOINT_USE_HTTPS", self.__MINIO_USE_HTTPS)
self.__MINIO_BUCKET_CHECK_ON_SAVE: bool = get_setting("MINIO_BUCKET_CHECK_ON_SAVE", False)

Expand Down Expand Up @@ -249,7 +249,8 @@ def url(self, name: str):
:return: (str) URL to object
"""
if self.is_bucket_public:
return f'{self.base_url_external}/{self.bucket}/{name}'
base_url = self.client._base_url.build("GET", self.__MINIO_REGION).geturl()
return f'{base_url}{self.bucket}/{name}'
if self.same_endpoints:
# in this scenario the fake client is not needed
client = self.client
Expand Down

0 comments on commit b1f32ca

Please sign in to comment.