[GH-ISSUE #1751] Blob.download_to_filename does not work #217

Open
opened 2026-03-03 12:09:13 +03:00 by kerem · 7 comments
Owner

Originally created by @Menghetz on GitHub (Sep 22, 2024).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/1751

I am having everytime my python scripts uses the blob.download_to_filename method.
I am running the fake-gcs-server using this command

docker run --rm -p 4443:4443 fsouza/fake-gcs-server -scheme http

Here below is my Python script

from google.auth.credentials import AnonymousCredentials
from google.cloud import storage
from pathlib import Path

client = storage.Client(
    credentials=AnonymousCredentials(),
    project="test",
    client_options={"api_endpoint": "http://127.0.0.1:4443"},
)
bucket = client.bucket("test-bucket")
# Create the bucket in the fake GCS server
if not bucket.exists():
    client.create_bucket("test-bucket")

# Upload all txt files from tests/data folder to the fake GCS server
data_folder = Path('tests/data')
txt_files = list(data_folder.glob('*.txt'))

for txt_file in txt_files:
    blob = bucket.blob(f'folder/{txt_file.name}')
    with open(txt_file, 'r') as f:
        blob.upload_from_string(f.read())
    print(f"Uploaded {txt_file.name} to fake GCS bucket.")

# List the Buckets
for bucket in client.list_buckets():
    print(f"Bucket: {bucket.name}\n")
    # List the Blobs in each Bucket
    for blob in bucket.list_blobs():
        print(f"Blob: {blob.name}")

        # Print the content of the Blob
        b = bucket.get_blob(blob.name)
        s = b.download_to_filename('test.json')
        print(f"Downloaded `{blob.name}")

And these are the execution logs

Uploaded file1.txt to fake GCS bucket.
Uploaded file2.txt to fake GCS bucket.
Bucket: test-bucket

Blob: folder/file1.txt

I can correctly upload files into the server, list the buckets and get blob info. But the code is stucked at download_to_filename

Here below is the error I am getting

requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/test-bucket/o/folder%2Ffile1.txt?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002B43E8FA120>: Failed to establish a new connection: [WinError 10049] The requested address is not valid in its context'))

Any idea about what the error could be?

Originally created by @Menghetz on GitHub (Sep 22, 2024). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/1751 I am having everytime my python scripts uses the blob.download_to_filename method. I am running the fake-gcs-server using this command `docker run --rm -p 4443:4443 fsouza/fake-gcs-server -scheme http` Here below is my Python script ``` from google.auth.credentials import AnonymousCredentials from google.cloud import storage from pathlib import Path client = storage.Client( credentials=AnonymousCredentials(), project="test", client_options={"api_endpoint": "http://127.0.0.1:4443"}, ) bucket = client.bucket("test-bucket") # Create the bucket in the fake GCS server if not bucket.exists(): client.create_bucket("test-bucket") # Upload all txt files from tests/data folder to the fake GCS server data_folder = Path('tests/data') txt_files = list(data_folder.glob('*.txt')) for txt_file in txt_files: blob = bucket.blob(f'folder/{txt_file.name}') with open(txt_file, 'r') as f: blob.upload_from_string(f.read()) print(f"Uploaded {txt_file.name} to fake GCS bucket.") # List the Buckets for bucket in client.list_buckets(): print(f"Bucket: {bucket.name}\n") # List the Blobs in each Bucket for blob in bucket.list_blobs(): print(f"Blob: {blob.name}") # Print the content of the Blob b = bucket.get_blob(blob.name) s = b.download_to_filename('test.json') print(f"Downloaded `{blob.name}") ``` And these are the execution logs ``` Uploaded file1.txt to fake GCS bucket. Uploaded file2.txt to fake GCS bucket. Bucket: test-bucket Blob: folder/file1.txt ``` I can correctly upload files into the server, list the buckets and get blob info. But the code is stucked at _download_to_filename_ Here below is the error I am getting ``` requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/test-bucket/o/folder%2Ffile1.txt?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002B43E8FA120>: Failed to establish a new connection: [WinError 10049] The requested address is not valid in its context')) ``` Any idea about what the error could be?
Author
Owner

@fsouza commented on GitHub (Sep 22, 2024):

Can you share the server logs?

<!-- gh-comment-id:2366831417 --> @fsouza commented on GitHub (Sep 22, 2024): Can you share the server logs?
Author
Owner

@Menghetz commented on GitHub (Sep 22, 2024):

Sure! Here they are.

C:\Users\matte>docker logs 1d70fe6796e0
time=2024-09-22T15:20:55.940Z level=INFO msg="server started at http://0.0.0.0:4443"
time=2024-09-22T15:21:05.211Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"GET /storage/v1/b/tests?fields=name&prettyPrint=false HTTP/1.1\" 404 119\n"
time=2024-09-22T15:21:05.223Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"POST /storage/v1/b?project=test&prettyPrint=false HTTP/1.1\" 200 333\n"
time=2024-09-22T15:21:05.243Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"POST /upload/storage/v1/b/tests/o?uploadType=multipart HTTP/1.1\" 200 791\n"
time=2024-09-22T15:21:05.261Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"POST /upload/storage/v1/b/tests/o?uploadType=multipart HTTP/1.1\" 200 790\n"
time=2024-09-22T15:21:05.264Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"GET /storage/v1/b?project=test&projection=noAcl&prettyPrint=false HTTP/1.1\" 200 370\n"
time=2024-09-22T15:21:05.267Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"GET /storage/v1/b/tests/o?projection=noAcl&prettyPrint=false HTTP/1.1\" 200 1618\n"
time=2024-09-22T15:21:05.270Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"GET /storage/v1/b/tests/o/folder%2Ffile1.txt?projection=noAcl&prettyPrint=false HTTP/1.1\" 200 612\n"
<!-- gh-comment-id:2366836996 --> @Menghetz commented on GitHub (Sep 22, 2024): Sure! Here they are. ``` C:\Users\matte>docker logs 1d70fe6796e0 time=2024-09-22T15:20:55.940Z level=INFO msg="server started at http://0.0.0.0:4443" time=2024-09-22T15:21:05.211Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"GET /storage/v1/b/tests?fields=name&prettyPrint=false HTTP/1.1\" 404 119\n" time=2024-09-22T15:21:05.223Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"POST /storage/v1/b?project=test&prettyPrint=false HTTP/1.1\" 200 333\n" time=2024-09-22T15:21:05.243Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"POST /upload/storage/v1/b/tests/o?uploadType=multipart HTTP/1.1\" 200 791\n" time=2024-09-22T15:21:05.261Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"POST /upload/storage/v1/b/tests/o?uploadType=multipart HTTP/1.1\" 200 790\n" time=2024-09-22T15:21:05.264Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"GET /storage/v1/b?project=test&projection=noAcl&prettyPrint=false HTTP/1.1\" 200 370\n" time=2024-09-22T15:21:05.267Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"GET /storage/v1/b/tests/o?projection=noAcl&prettyPrint=false HTTP/1.1\" 200 1618\n" time=2024-09-22T15:21:05.270Z level=INFO msg="172.17.0.1 - - [22/Sep/2024:15:21:05 +0000] \"GET /storage/v1/b/tests/o/folder%2Ffile1.txt?projection=noAcl&prettyPrint=false HTTP/1.1\" 200 612\n" ```
Author
Owner

@dtabata commented on GitHub (Mar 11, 2025):

@Menghetz
Hello.
I was having the same error too, but Blob.download_to_filename() solved it.
I just wish get_blob(...).download_to_filename(...) would work properly as this is a source of confusion.

# Does not work 🙅‍♂️
from google.cloud import storage


storage_client = storage.Client(credentials=AnonymousCredentials(), project='test')
bucket = storage_client.bucket('test-bucket')
blob = bucket.get_blob('test.txt')
with tempfile.NamedTemporaryFile() as temp_file:
    blob.download_to_filename(temp_file.name)


# Work 🙆‍♂️
from google.cloud import storage
from google.cloud.storage.blob import Blob


storage_client = storage.Client(credentials=AnonymousCredentials(), project='test')
with tempfile.NamedTemporaryFile() as temp_file:
    Blob.from_string('gs://test-bucket/test.txt', client=storage_client).download_to_filename(temp_file.name)
<!-- gh-comment-id:2712618654 --> @dtabata commented on GitHub (Mar 11, 2025): @Menghetz Hello. I was having the same error too, but Blob.download_to_filename() solved it. I just wish `get_blob(...).download_to_filename(...)` would work properly as this is a source of confusion. ``` python # Does not work 🙅‍♂️ from google.cloud import storage storage_client = storage.Client(credentials=AnonymousCredentials(), project='test') bucket = storage_client.bucket('test-bucket') blob = bucket.get_blob('test.txt') with tempfile.NamedTemporaryFile() as temp_file: blob.download_to_filename(temp_file.name) # Work 🙆‍♂️ from google.cloud import storage from google.cloud.storage.blob import Blob storage_client = storage.Client(credentials=AnonymousCredentials(), project='test') with tempfile.NamedTemporaryFile() as temp_file: Blob.from_string('gs://test-bucket/test.txt', client=storage_client).download_to_filename(temp_file.name) ```
Author
Owner

@fsouza commented on GitHub (Mar 11, 2025):

bucket.get_blob(...).download_to_filename(...) should work. See the examples folder: https://github.com/fsouza/fake-gcs-server/blob/main/examples/python/python.py

<!-- gh-comment-id:2713720805 --> @fsouza commented on GitHub (Mar 11, 2025): `bucket.get_blob(...).download_to_filename(...)` should work. See the examples folder: https://github.com/fsouza/fake-gcs-server/blob/main/examples/python/python.py
Author
Owner

@dtabata commented on GitHub (Mar 11, 2025):

@fsouza
Yes, I am aware of the Python EXAMPLE.
But for some reason it does not work.

from google.auth.credentials import AnonymousCredentials
from google.cloud import storage
from google.cloud.storage.blob import Blob


class StorageManager:
    def __init__(self):
        self.storage_client = storage.Client(credentials=AnonymousCredentials(), project='test')

    def download(self, bucket_name: str, blob_name: str, destination: str, /) -> None:
        # bucket = self.storage_client.get_bucket(bucket_name)  # OK
        # blob = bucket.get_blob(blob_name)                     # OK
        # blob.download_to_filename(destination)                # Does not work 🤔

        # Work 🙆‍♂️
        Blob.from_string(f'gs://{bucket_name}/{blob_name}', client=self.storage_client).download_to_filename(destination)

The error log is as follows

error logs
[2025-03-11 12:15:43,105][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff88195580>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 0.0s ...
[2025-03-11 12:15:43,160][DEBUG] Starting new HTTP connection (2): 0.0.0.0:4443
[2025-03-11 12:15:43,161][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff88195a00>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 1.9s ...
[2025-03-11 12:15:45,050][DEBUG] Starting new HTTP connection (3): 0.0.0.0:4443
[2025-03-11 12:15:45,053][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff88195eb0>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 1.7s ...
[2025-03-11 12:15:46,724][DEBUG] Starting new HTTP connection (4): 0.0.0.0:4443
[2025-03-11 12:15:46,728][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff88196c30>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 0.9s ...
[2025-03-11 12:15:47,594][DEBUG] Starting new HTTP connection (5): 0.0.0.0:4443
[2025-03-11 12:15:47,598][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff881963f0>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 1.7s ...
[2025-03-11 12:15:49,281][DEBUG] Starting new HTTP connection (6): 0.0.0.0:4443
[2025-03-11 12:15:49,283][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff881965d0>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 2.2s ...
[2025-03-11 12:15:51,486][DEBUG] Starting new HTTP connection (7): 0.0.0.0:4443
[2025-03-11 12:15:51,488][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff88a9bd40>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 8.1s ...
...
..
.
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 841, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/retry.py", line 519, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff88b1a8d0>: Failed to establish a new connection: [Errno 111] Connection refused'))

Here is the log of fake-gcs-server at this time.

fake-gcs-server logs
time=2025-03-11T12:36:14.652Z level=INFO msg="172.30.0.2 - - [11/Mar/2025:12:36:14 +0000] \"GET /storage/v1/b/sample-bucket?projection=noAcl&prettyPrint=false HTTP/1.1\" 200 349\n"
time=2025-03-11T12:36:14.660Z level=INFO msg="172.30.0.2 - - [11/Mar/2025:12:36:14 +0000] \"GET /storage/v1/b/sample-bucket/o/hoge.xlsx?projection=noAcl&prettyPrint=false HTTP/1.1\" 200 684\n"

The compose.yml and pyproject.toml are as follows
Are there any flaws in the configuration?

compose.yml and pyproject.toml
services:
  api:
    build:
      context: ./api
      dockerfile: Dockerfile
    environment:
      - STORAGE_EMULATOR_HOST='http://storage:4443'
    volumes:
      - ./api:/workspace
    ports:
      - "8001:8080"
    tty: true
    command: functions-framework --debug --target=main --signature-type=http

  storage:
    image: fsouza/fake-gcs-server
    volumes:
      - ./docker/fake-gcs-server/buckets:/data
    ports:
      - "4443:4443"
    command: -scheme http -public-host 0.0.0.0
[project]
name = "api"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "feedparser>=6.0.11",
    "functions-framework>=3.8.2",
    "google-cloud-logging>=3.11.4",
    "google-cloud-storage>=3.1.0",
    "openpyxl>=3.1.5",
    "pandas>=2.2.3",
    "python-dotenv>=1.0.1",
    "requests>=2.32.3",
]
<!-- gh-comment-id:2713987670 --> @dtabata commented on GitHub (Mar 11, 2025): @fsouza Yes, I am aware of the Python EXAMPLE. But for some reason it does not work. ``` Python from google.auth.credentials import AnonymousCredentials from google.cloud import storage from google.cloud.storage.blob import Blob class StorageManager: def __init__(self): self.storage_client = storage.Client(credentials=AnonymousCredentials(), project='test') def download(self, bucket_name: str, blob_name: str, destination: str, /) -> None: # bucket = self.storage_client.get_bucket(bucket_name) # OK # blob = bucket.get_blob(blob_name) # OK # blob.download_to_filename(destination) # Does not work 🤔 # Work 🙆‍♂️ Blob.from_string(f'gs://{bucket_name}/{blob_name}', client=self.storage_client).download_to_filename(destination) ``` The error log is as follows <details> <summary>error logs</summary> ``` shell [2025-03-11 12:15:43,105][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff88195580>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 0.0s ... [2025-03-11 12:15:43,160][DEBUG] Starting new HTTP connection (2): 0.0.0.0:4443 [2025-03-11 12:15:43,161][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff88195a00>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 1.9s ... [2025-03-11 12:15:45,050][DEBUG] Starting new HTTP connection (3): 0.0.0.0:4443 [2025-03-11 12:15:45,053][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff88195eb0>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 1.7s ... [2025-03-11 12:15:46,724][DEBUG] Starting new HTTP connection (4): 0.0.0.0:4443 [2025-03-11 12:15:46,728][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff88196c30>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 0.9s ... [2025-03-11 12:15:47,594][DEBUG] Starting new HTTP connection (5): 0.0.0.0:4443 [2025-03-11 12:15:47,598][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff881963f0>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 1.7s ... [2025-03-11 12:15:49,281][DEBUG] Starting new HTTP connection (6): 0.0.0.0:4443 [2025-03-11 12:15:49,283][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff881965d0>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 2.2s ... [2025-03-11 12:15:51,486][DEBUG] Starting new HTTP connection (7): 0.0.0.0:4443 [2025-03-11 12:15:51,488][DEBUG] Retrying due to HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff88a9bd40>: Failed to establish a new connection: [Errno 111] Connection refused')), sleeping 8.1s ... ... .. . Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 667, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 841, in urlopen retries = retries.increment( ^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/urllib3/util/retry.py", line 519, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='0.0.0.0', port=4443): Max retries exceeded with url: /download/storage/v1/b/sample-bucket/o/hoge.xlsx?alt=media (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff88b1a8d0>: Failed to establish a new connection: [Errno 111] Connection refused')) ``` </details> <br /> Here is the log of fake-gcs-server at this time. <details> <summary>fake-gcs-server logs</summary> ``` shell time=2025-03-11T12:36:14.652Z level=INFO msg="172.30.0.2 - - [11/Mar/2025:12:36:14 +0000] \"GET /storage/v1/b/sample-bucket?projection=noAcl&prettyPrint=false HTTP/1.1\" 200 349\n" time=2025-03-11T12:36:14.660Z level=INFO msg="172.30.0.2 - - [11/Mar/2025:12:36:14 +0000] \"GET /storage/v1/b/sample-bucket/o/hoge.xlsx?projection=noAcl&prettyPrint=false HTTP/1.1\" 200 684\n" ``` </details> <br /> The compose.yml and pyproject.toml are as follows Are there any flaws in the configuration? <details> <summary>compose.yml and pyproject.toml</summary> ``` compose.yml services: api: build: context: ./api dockerfile: Dockerfile environment: - STORAGE_EMULATOR_HOST='http://storage:4443' volumes: - ./api:/workspace ports: - "8001:8080" tty: true command: functions-framework --debug --target=main --signature-type=http storage: image: fsouza/fake-gcs-server volumes: - ./docker/fake-gcs-server/buckets:/data ports: - "4443:4443" command: -scheme http -public-host 0.0.0.0 ``` ``` pyproject.toml [project] name = "api" version = "0.1.0" description = "Add your description here" readme = "README.md" requires-python = ">=3.12" dependencies = [ "feedparser>=6.0.11", "functions-framework>=3.8.2", "google-cloud-logging>=3.11.4", "google-cloud-storage>=3.1.0", "openpyxl>=3.1.5", "pandas>=2.2.3", "python-dotenv>=1.0.1", "requests>=2.32.3", ] ``` </details>
Author
Owner

@fsouza commented on GitHub (Mar 11, 2025):

The example is validated by GitHub Actions on every change. You can see it working here: https://github.com/fsouza/fake-gcs-server/actions/runs/13772629106/job/38514639482

Please make sure you're following the instructions in the example file, or double check how CI runs it: https://github.com/fsouza/fake-gcs-server/blob/main/ci/run-python-example.sh

<!-- gh-comment-id:2715034505 --> @fsouza commented on GitHub (Mar 11, 2025): The example is validated by GitHub Actions on every change. You can see it working here: https://github.com/fsouza/fake-gcs-server/actions/runs/13772629106/job/38514639482 Please make sure you're following the instructions in the example file, or double check how CI runs it: https://github.com/fsouza/fake-gcs-server/blob/main/ci/run-python-example.sh
Author
Owner

@dtabata commented on GitHub (Mar 11, 2025):

@fsouza
thx.
local code to bucket.get_blob(...) to bucket.blob(...) , which cured the problem.
( Reverting to `get_blob(...)' will cause the problem to reoccur )

Sorry for the inconvenience 🙇‍♂️

storage_client = storage.Client(credentials=AnonymousCredentials(), project='test')
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(blob_name)  # rewrite `get_blob()` to `blob()`
blob.download_to_filename(destination)
<!-- gh-comment-id:2715878925 --> @dtabata commented on GitHub (Mar 11, 2025): @fsouza thx. local code to `bucket.get_blob(...) `to `bucket.blob(...) `, which cured the problem. ( Reverting to `get_blob(...)' will cause the problem to reoccur ) Sorry for the inconvenience 🙇‍♂️ ``` python storage_client = storage.Client(credentials=AnonymousCredentials(), project='test') bucket = storage_client.bucket(bucket_name) blob = bucket.blob(blob_name) # rewrite `get_blob()` to `blob()` blob.download_to_filename(destination) ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#217
No description provided.