theriverman / django-minio-backend

Minio Backend for Django
https://pypi.org/project/django-minio-backend/
MIT License
112 stars 22 forks source link

external endpoint are broken #42

Closed eikichi18 closed 1 year ago

eikichi18 commented 1 year ago

Hi, I've upgrade my project to version 3.4.0 of django_minio_backend and now external URL seems to be broken. Correct me if I'm wrong but now MINIO_EXTERNAL_ENDPOINT seems to not get used to calculate external url.

Am I right?

theriverman commented 1 year ago

Hi, It is supposed to be used. Go to https://github.com/theriverman/django-minio-backend/blob/master/django_minio_backend/models.py hit Ctrl + F and search for MINIO_EXTERNAL_ENDPOINT.

Could you share the relevant lines from your settings.py maybe?

eikichi18 commented 1 year ago

Hi,

sure my settings.py for MINIO are:

MINIO_ENDPOINT = os.getenv("MINIO_ENDPOINT", "minio:9000")
MINIO_EXTERNAL_ENDPOINT = os.getenv(
    "MINIO_EXTERNAL_ENDPOINT", "localhost:9000"
)
MINIO_EXTERNAL_ENDPOINT_USE_HTTPS = (
    False
    if os.getenv("MINIO_EXTERNAL_ENDPOINT_USE_HTTPS") == "False"
    else True
)
MINIO_ACCESS_KEY = os.getenv("MINIO_ACCESS_KEY")
MINIO_SECRET_KEY = os.getenv("MINIO_SECRET_KEY")
MINIO_USE_HTTPS = False if os.getenv("MINIO_USE_HTTPS") == "False" else True
MINIO_URL_EXPIRY_HOURS = timedelta(
    days=int(os.getenv("MINIO_URL_EXPIRY_HOURS", "7"))
)
MINIO_CONSISTENCY_CHECK_ON_START = (
    False
    if os.getenv("MINIO_CONSISTENCY_CHECK_ON_START", "False") == "False"
    else True
)
MINIO_PRIVATE_BUCKETS = [
    "dashboardapp-media-bucket",
]
MINIO_PUBLIC_BUCKETS = [
    "dashboardapp-static-bucket",
]
MINIO_POLICY_HOOKS: List[Tuple[str, dict]] = []
MINIO_BUCKET_CHECK_ON_SAVE = (
    False
    if os.getenv("MINIO_BUCKET_CHECK_ON_SAVE", "False") == "False"
    else True
)

I run my application in a containerized environment. When the file's URL are calculated with version 3.4.0 starts with minio:9000 not localhost:9000.

I've search in models.py and this what I see:

Schermata 2023-03-21 alle 17 34 36 Schermata 2023-03-21 alle 17 34 48 Schermata 2023-03-21 alle 17 35 44

3.4.0:

Schermata 2023-03-21 alle 17 44 16

3.3.2

Schermata 2023-03-21 alle 17 44 40
theriverman commented 1 year ago

sorry for making you wait, @eikichi18 i could reproduce the issue and i've already found the root cause of it. it has been fixed in 1bd19be. we've introduced this bug while adding region-awareness to the package in #34.

i've pushed version 3.5.0 to PyPI which now respects the value of MINIO_EXTERNAL_ENDPOINT while generating public urls (private urls were generated correctly already).

@subho007 fyi, this might be impacting you too. consider upgrading to 3.5.0

subho007 commented 1 year ago

@theriverman thanks for the heads up, I'm sorry there was a regression error which came up. Thanks for the fix 😊

eikichi18 commented 1 year ago

Thanks for the fix :)