关于 Blobstore 和 Google Cloud Storage (GCS) 的许多问题和答案已有两三年历史,而这些年情况发生了巨大变化。 GCS 不再是一项独立的服务。这是融合的 https://developers.google.com/storage/docs/google-integration现在进入 Google App Engine (GAE)。
谷歌似乎大力推动 GCSBlobstore 已弃用 https://developers.google.com/appengine/docs/python/blobstore/#Python_Writing_files_to_the_Blobstore, 例如,
此处用于将文件写入 Blobstore 的文件 API 功能已
已弃用,并将在未来某个时间删除
支持将文件写入 Google Cloud Storage 并使用 Blobstore
为他们服务。
我相信现在是切换到 GCS 的时候了。
例如,www.example.com
是一个基于 GAE 构建的网站,而example.jpg
是存储在 GCS 上的图像,我想使用 url 提供该图像http://www.example.com/images/example.jpg
这在过去是不可能的,但现在这是可能的,感谢一体化 https://developers.google.com/storage/docs/google-integration.
我找到了这个:
https://developers.google.com/appengine/docs/python/googlecloudstorageclient/ https://developers.google.com/appengine/docs/python/googlecloudstorageclient/
says:
当 Blobstore API 与 Images API 一起使用时,您会得到
提供图像的强大方法,因为您可以直接提供图像
来自 GCS,绕过 App Engine 应用程序,从而节省实例时间
成本。
我知道如何“绕过 App Engine 应用程序”。有没有关于如何在使用 Blobstore API 和 Images API 提供图像时绕过 GAE 的示例?
说明在这里:https://developers.google.com/appengine/docs/python/images/functions#Image_get_serving_url https://developers.google.com/appengine/docs/python/images/functions#Image_get_serving_url
从 Google Cloud Storage 中托管的图像开始。
首先,使用 Blobstore API 的 create_gs_key() 函数为 GCS 图像对象生成 blob 键。然后,将该 blob 键传递到图像 API 的 get_serving_url() 函数中。
图像 API 将为您提供一个特殊的 URL,该 URL 会跳过您的应用程序引擎应用程序并直接提供图像。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)