You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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
And these are the execution logs
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
Any idea about what the error could be?
The text was updated successfully, but these errors were encountered: