使用Blobstore API和Images API直接从GAE中的GCS提供图像 [英] Serving images directly from GCS in GAE using Blobstore API and Images API

查看:141
本文介绍了使用Blobstore API和Images API直接从GAE中的GCS提供图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于Blobstore和Google云存储(GCS)的许多问题和答案已有两三年历史,而这些年来事情发生了翻天覆地的变化。 GCS不再是独立的服务。现在将集成到Google App Engine(GAE)中。

Google似乎推动GCS如此艰难,以至于,例如,


这里使用的Files API功能将文件写入Blobstore已弃用
,并将在未来的某个时间删除,
赞成将文件写入Google Cloud Storage,并使用Blobstore以
为它们提供服务。


我认为现在是切换到GCS的时候了。例如, www.example.com 是建立在GAE上的网站,而 example.jpg 是存储在GCS上的图片,我想使用url http://www.example.com/images/example.jpg $ b

过去这是不可能的,但现在可以感谢 integration



我发现这个:

https://developers.google.com/appengine/docs/python/googlecloudstorageclient/
说:


当Blobstore API与Images API一起使用时,您会得到
强大的服务图像的方式,因为您可以直接从GCS提供
的图片,绕过App Engine应用程序,节省实例小时
的费用。


我知道如何<强制绕过App Engine应用程序。在使用Blobstore API和Images API处理图像时如何绕过GAE有任何例子吗? 解决方案

说明如下: a href =https://developers.google.com/appengine/docs/python/images/functions#Image_get_serving_url =nofollow> https://developers.google.com/appengine/docs/python/images/功能#Image_get_serving_url



从Google云端存储托管的图片开始。 首先,使用Blobstore API的create_gs_key()函数为您的GCS图像对象生成一个blob密钥。然后,将该blob键传递给Image API的get_serving_url()函数。



Image API会为您提供一个特殊的URL,以跳过您的应用引擎应用并提供图像直接。


Many questions and answers on Blobstore and Google Cloud Storage(GCS) are two or three years old, while things change dramatically these years. GCS is no longer a standalone service. It is integrated into Google App Engine (GAE) now.

Google seems to push GCS so hard that Blobstore is deprecated, for example,

The Files API feature used here to write files to Blobstore has been deprecated and is going to be removed at some time in the future, in favor of writing files to Google Cloud Storage and using Blobstore to serve them.

I believe it is high time to switch to GCS.

For example, www.example.com is a site built on GAE, while example.jpg is an image stored on GCS, I want to serve the image using the url http://www.example.com/images/example.jpg

This used to be impossible, but now it is possible thanks to the integration.

I found this:

https://developers.google.com/appengine/docs/python/googlecloudstorageclient/ says:

When the Blobstore API is used together with the Images API, you get a powerful way to serve images, because you can serve images directly from GCS, bypassing the App Engine app, which saves on instance hour costs.

I do know how to 'bypassing the App Engine app'. Is there any example on how to bypass GAE while serving the images using Blobstore API and Images API?

解决方案

Instructions are here: https://developers.google.com/appengine/docs/python/images/functions#Image_get_serving_url

Start with an image hosted in Google Cloud Storage.

First, use the Blobstore API's create_gs_key() function to generate a blob key for your GCS image object. Then, pass that blob key into the Image API's get_serving_url() function.

The Image API will give you a special URL that skips over your app engine app and serves the image directly.

这篇关于使用Blobstore API和Images API直接从GAE中的GCS提供图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆