How to serve Google Cloud Storage images?(如何提供 Google Cloud Storage 图片?)
问题描述
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?
The blobstore and images APIs are available only within the App Engine runtime environment. To run them inside compute engine you can:
Run them inside Managed VMs (the GAE runtime environment on GCE)
Run them on your own infrastructure or GCE using a GAE API emulator (such as AppScale)
Use public APIs (such as Google Cloud Storage) instead
Some App Engine services (such as Datastore) now also expose public APIs that you can use from GCE.
这篇关于如何提供 Google Cloud Storage 图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何提供 Google Cloud Storage 图片?


- 沿轴计算直方图 2022-01-01
- padding='same' 转换为 PyTorch padding=# 2022-01-01
- pytorch 中的自适应池是如何工作的? 2022-07-12
- python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令 2022-01-01
- 如何在 python3 中将 OrderedDict 转换为常规字典 2022-01-01
- 分析异常:路径不存在:dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data; 2022-01-01
- python-m http.server 443--使用SSL? 2022-01-01
- 如何在 Python 的元组列表中对每个元组中的第一个值求和? 2022-01-01
- 使用Heroku上托管的Selenium登录Instagram时,找不到元素';用户名'; 2022-01-01
- 如何将一个类的函数分成多个文件? 2022-01-01