-
Notifications
You must be signed in to change notification settings - Fork 168
Closed
Labels
api: storageIssues related to the googleapis/python-storage API.Issues related to the googleapis/python-storage API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
I am trying to download file content to a file using blob.download_to_file function but it's getting 400 from from GCS APIs while fetching the file content.
Environment details
- MacOS Catalina 10.15
- Python version:
3.8 - pip version:
20.1.1 google-cloud-storageversion:1.3
Code example
def write_to_file(self, file_path, file_obj, encryption_key):
"""
write file content to file obj.
"""
# TODO: add error check for `file_obj`
blob = self.get_blob(file_path, encryption_key=encryption_key)
blob.download_to_file(file_obj)
file_obj.seek(0)
return file_objStack trace
File "/Users/PJ/Documents/Workspace/projects/white/box/lib/gcs/storage.py", line 68, in write_to_file
blob.download_to_file(file_obj)
File "/Users/PJ/.local/share/virtualenvs/white-Pt7g6jSz/lib/python3.8/site-packages/google/cloud/storage/blob.py", line 1008, in download_to_file
_raise_from_invalid_response(exc)
File "/Users/PJ/.local/share/virtualenvs/white-Pt7g6jSz/lib/python3.8/site-packages/google/cloud/storage/blob.py", line 3262, in _raise_from_invalid_response
raise exceptions.from_http_status(response.status_code, message, response=response)
google.api_core.exceptions.BadRequest: 400 GET https://storage.googleapis.com/download/storage/v1/b/spotlight-stag/o/COVReport_Final_20200320-2020-07-29-165239-defd0fdbe121411b8a3a419f87c5594b.pdf?generation=1596041564648328&alt=media: ('Request failed with status code', 400, 'Expected one of', <HTTPStatus.OK: 200>, <HTTPStatus.PARTIAL_CONTENT: 206>)
Thanks!
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the googleapis/python-storage API.Issues related to the googleapis/python-storage API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.