Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
779 views
in Technique[技术] by (71.8m points)

python - How to serve Google Cloud Storage images?

I want google.appengine.ext.blobstore and google.appengine.api.images to work outside of App Engine. Do these modules require App Engine in order to work? I want to create public but not guessable URLs of my images on Google Cloud Storage and serve them via Django.

I read that this is done with google.appengine.ext.blobstore.create_gs_key() and google.appengine.api.images.get_serving_url(). This is what I have so far:

from google.appengine.api import images
from google.appengine.ext import blobstore

bucketname = 'mybucket'

gcs_object_name = '/gs/mybucket/vincent-van-gogh/the-starry-night.jpg'
blob_key = blobstore.create_gs_key(gcs_object_name)
image_url = images.get_serving_url(blob_key)

And image_url is supposed to be a public but not guessable URL of my image. If I run this code, the error is

AssertionError: No api proxy found for service "blobstore"

This suggests blobstore needs a proxy, aka App Engine, in order to work its magic. Can App Engine modules work outside of App Engine? The docs say the above is a powerful way to serve images because I can generate a URL for each image and also resize the image dynamically.

Will this strategy work or is there a better way to serve images from Google Cloud Storage with Django?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...