googleapis/python-storage

media_link & self_link in blob do not update when client option "api_endpoint" is set

andrewlayer opened this issue · 2 comments

I am not sure this is intentional or not, but I had problems with it when using fake-gcs-server. I attempted to set the api_endpoint field to http://localhost:4443, but the media_link and self_link hosts continue to be 0.0.0.0. Here is the code used to configure the client:

client = storage.Client(
    credentials=AnonymousCredentials(),
    project="test",
    client_options={"api_endpoint": "http://localhost:4443"},
)

Here is an image of the blob during execution:
Screenshot 2024-05-09 at 7 00 18 PM

This become problematic because we are running in docker container that needs the hostname to be custom. Let me know if you need more details!

Hi @andrewlayer is this issue only happening when running against fake-gcs-server? If so, I would guess the issue might lie on the fake-gcs-server side as the library itself populates these fields based on the response received from the server. I took a quick look and looks like it might be something with the configuration of fake-gcs-server.

You were correct ddelgrosso1, I needed to add a flag in my YAML config for fake-gcs-server. Here is is for reference for anyone who stumbles across this:

  fake-gcs-server:
      container_name: fake-gcs-server
      image: fsouza/fake-gcs-server
      command: -scheme http -external-url http://fake-gcs-server:4443
      ports:
          - '4443:4443'
      volumes:
          - ${PWD}/bucket:/data
      networks:
          - net
      depends_on:
          - api
      profiles: 
          - "GCP_EMULATOR_MODE"

Thanks for you help.