Get Google Cloud Storage Blob Url via Id/File path (Python)

Refer Setup Google Cloud Storage access (Python).

storage_client = NoneDEFAULT_STORAGE_BUCKET_NAME = ''def init_storage():    from import storage    global storage_client    if storage_client:        return storage_client    # on cloud functions    storage_client = storage.Client()    # on external server    # storage_client = storage.Client.from_service_account_json('keys/PROJECT_ID-storage.json')    return storage_client
storage_client = init_storage()gcs_id = 'gs://'blob = Blob.from_string(gcs_id, client=storage_client)blob_url = blob.generate_signed_url(expiration=timedelta(hours=1))

NOTE: Need Storage Admin permission to call Blob.generate_signed_url

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.