Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

download_as_string method for Cloud Storage fails #101

Closed
peeyushagg opened this issue Apr 9, 2020 · 5 comments
Closed

download_as_string method for Cloud Storage fails #101

peeyushagg opened this issue Apr 9, 2020 · 5 comments
Assignees
Labels
api: storage Issues related to the googleapis/python-storage API. needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue.

Comments

@peeyushagg
Copy link

I feel this could be similar to googleapis/google-cloud-python#3747
But the fix suggested didn't work

Environment details

  1. Google Cloud Storage
  2. Ubuntu 1.18 | Mac OSX - Mojave 10.14.6 (18G84)
  3. Python 3.7.6
  4. google-cloud-storage==1.23.0, requests=2.22.0

Steps to reproduce

  1. Upload a PNG image to google cloud storage
  2. Try to retrieve the image using the download_as_string method provided by the Blob object

Code example

client = storage.Client()
bucket = client.get_bucket(<BUCKET_NAME>)
blob = bucket.blob("<BLOB_NAME")
content = blob.download_as_string(raw_download=True)

Stack trace

Traceback (most recent call last):
  File "appengine_modules/tests/cloud_images_test.py", line 134, in test_get_data
    print(photo_client.get_image_data(NAME))
  File "/Users/pkagga/workspace/mezi/mezi-appengine/appengine_modules/cloud_images.py", line 127, in get_image_data
    return blob.download_as_string(raw_download=True)
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 802, in download_as_string
    raw_download=raw_download,
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 719, in download_to_file
    transport, file_obj, download_url, headers, start, end, raw_download
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 643, in _do_download
    download.consume(transport)
  File "/Users/pkagga/Downloads/google-cloud-sdk/platform/google_appengine/google/resumable_media/requests/download.py", line 272, in consume
    self._write_to_stream(result)
  File "/Users/pkagga/Downloads/google-cloud-sdk/platform/google_appengine/google/resumable_media/requests/download.py", line 214, in _write_to_stream
    with response:
AttributeError: __enter__```

@busunkim96 busunkim96 transferred this issue from googleapis/google-cloud-python Apr 9, 2020
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/python-storage API. label Apr 9, 2020
@busunkim96
Copy link
Contributor

Could you try running the code in a fresh virtual environment?

python3 -m  venv env
source env/bin/activate
python3 -m pip install google-cloud-storage

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Apr 10, 2020
@HemangChothani HemangChothani added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. labels Apr 10, 2020
@HemangChothani HemangChothani self-assigned this Apr 10, 2020
@HemangChothani
Copy link
Contributor

@peeyushagg I have tried to reproduce with your given details , but unable to do that.

Try running the code with fresh environment as mentioned above or update the libraries .

Environment Details:

  1. google-cloud-storage==1.27.0, requests==2.23.0
  2. google-resumable-media==0.5.0
  3. Python 3.7

@HemangChothani HemangChothani added the needs more info This issue needs more information from the customer to proceed. label Apr 20, 2020
@HemangChothani
Copy link
Contributor

@peeyushagg any update from your side?

@HemangChothani
Copy link
Contributor

.@peeyushagg Are you still facing the same issue? I have tried again but not able to reproduce this issue.

@HemangChothani
Copy link
Contributor

Please follow-up / reopen if you can provide more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/python-storage API. needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants