minio / minio-py

MinIO Client SDK for Python
https://docs.min.io/docs/python-client-quickstart-guide.html
Apache License 2.0
822 stars 318 forks source link

Enable MINIO_SERVER_URL for Generating Presigned URLs in Local Development Environments #1427

Closed hanieas closed 2 months ago

hanieas commented 2 months ago

Description:

In a local development environment, I am running Minio using Docker Compose with the following configuration:

minio:
  image: minio/minio
  ports:
    - "9000:9000"
    - "9001:9001"
  environment:
    - MINIO_ROOT_USER = 
    - MINIO_ROOT_PASSWORD= 
    - MINIO_SERVER_URL = "http://localhost:9000"
  command: server --console-address ":9001" /data

I have set the environment variable MINIO_SERVER_URL=http://localhost:9000 to help the Minio console generate pre-signed URLs.

Screenshot 2024-07-05 at 11 23 28 PM

However, the get_presigned_url() function within the Minio client SDK uses the internal container endpoint (minio:9000). As a result, the generated pre-signed URL looks like http://minio:9000/bucket/file.png?, which is not reachable from the host machine.

Proposal

To better support local development environments, I propose adding an optional parameter to the Minio class to specify the minio_server_url. This URL would be used when generating pre-signed URLs, ensuring they are accessible from the host machine. Is it possible to work on this change and create a PR? I believe this enhancement would significantly improve the developer experience when working with Minio in local environments.

balamurugana commented 2 months ago

minio-py generates presigned URLs as per endpoint passed to Minio class. If you pass wrong value, it generates wrong URLs. How you use MinIO server is irrelevant here.