unable to download files from google cloud storage

I am trying to download a file from my google cloud storage using ..

GCP_BUCKET_NAME = "my-learning-bucket"
storage_bucket = storage_client.bucket(GCP_BUCKET_NAME)


def download_object(download_obj_name):
    blob = storage_bucket.blob(download_obj_name)
    blob.download_to_file_name(f"downloads/data.db")

But it gives me error:

Traceback (most recent call last):
  File "/Users/asnimansari/Desktop/tradestation/ares/main.py", line 22, in <module>
    root.run_click_commands()
  File "/Users/asnimansari/.pyenv/versions/3.9.4/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/Users/asnimansari/.pyenv/versions/3.9.4/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/Users/asnimansari/.pyenv/versions/3.9.4/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/asnimansari/.pyenv/versions/3.9.4/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/asnimansari/.pyenv/versions/3.9.4/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/Users/asnimansari/Desktop/tradestation/ares/commands/import_data.py", line 9, in import_data
    import_latest_data_from_gc()
  File "/Users/asnimansari/Desktop/tradestation/ares/helpers/import_data_from_gc.py", line 8, in import_latest_data_from_gc
    db_names_in_gcp = get_db_names_in_gcp()
  File "/Users/asnimansari/Desktop/tradestation/ares/helpers/gcp.py", line 29, in get_db_names_in_gcp
    donwload_object(bobu)
  File "/Users/asnimansari/Desktop/tradestation/ares/helpers/gcp.py", line 13, in donwload_object
    blob = storage_bucket.blob(download_obj_name)
  File "/Users/asnimansari/.pyenv/versions/3.9.4/lib/python3.9/site-packages/google/cloud/storage/bucket.py", line 688, in blob
    return Blob(
  File "/Users/asnimansari/.pyenv/versions/3.9.4/lib/python3.9/site-packages/google/cloud/storage/blob.py", line 205, in __init__
    name = _bytes_to_unicode(name)
  File "/Users/asnimansari/.pyenv/versions/3.9.4/lib/python3.9/site-packages/google/cloud/_helpers.py", line 389, in _bytes_to_unicode
    raise ValueError("%r could not be converted to unicode" % (value,))
ValueError: <Blob: tradeenginedata, quotes/quotes_2021-06-10.db, 1623310593606516> could not be converted to unicode

The file is a sqlite database.



Read more here: https://stackoverflow.com/questions/67922750/unable-to-download-files-from-google-cloud-storage

Content Attribution

This content was originally published by Asnim P Ansari at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: