'Combining google.cloud.storage.blob.Blob and google.appengine.api.images.get_serving_url

I've got images stored as Blobs in Google Cloud Storage and I can see amazing capabilities offered by get_serving_url() which requires a blob_key as its first parameter. But I cannot see anyway to get a key from the Blob - am I mixing up multiple things called Blobs?

I'm using Python3 on GAE.



Solution 1:[1]

Try the code below but you'll need to first enable the Bundled Services API

from google.appengine.ext import blobstore

# Create the cloud storage file name
blobstore_filename = f"/gs/{<your_file_name>}"

# Now create the blob_key from the cloud storage file name
blob_key = blobstore.create_gs_key(blobstore_filename)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 NoCommandLine