Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Storage - Python Client - Get Link URL of a blob

The Link URL at the Object details in the GoogleCloudStorage browser follows the template:

https://storage.cloud.google.com/<project_name>/<file_name>?authuser=0&organizationId=<org_id>

I'm trying to get the exact same link using the python package google-cloud-storage. Diving into the blob properties I've found the followings (none of which are exactly what I need):

  • self_link: https://www.googleapis.com/storage/v1/b/<project_name>/o/<file_name>
  • media_link: https://storage.googleapis.com/download/storage/v1/b/<project_name>/o/<file_name>?generation=<gen_id>&alt=media

Note: If I replace storage.googleapis.com with storage.cloud.google.com at the media_link I get to download the file as I expect (getting asked for a valid Google Account with the required permissions).

Is there any way to get the link directly from the blob object?

like image 855
Álvaro Rd Avatar asked Nov 06 '22 09:11

Álvaro Rd


1 Answers

Here the pattern:

https://storage.googleapis.com/<BUCJET_NAME>/path/to/file

For example, for a bucket my_bucket and a file stored in this path folder_save/2020-01-01/backup.zip, you have this url https://storage.googleapis.com/my_bucket/folder_save/2020-01-01/backup.zip

like image 106
guillaume blaquiere Avatar answered Nov 13 '22 22:11

guillaume blaquiere