sei*_*elj 8 google-app-engine blobstore google-cloud-storage
使用最新的GAE SDK(1.9.17),我遵循了使用blobstore和图像库提供谷歌云存储映像的所有说明,但在本地它给了我500错误.将应用程序部署到生产服务器,提供图像可以正常工作.但是,这非常烦人,因为我需要在本地开发,而我的项目是图像密集型的.
这在生产中很好用:
key = blobstore.create_gs_key('/gs/my_bucket/my_folder/my_image.jpg')
url = images.get_serving_url(key)
Run Code Online (Sandbox Code Playgroud)
在制作时,服务网址如下:
http://lh6.ggpht.com/ow6Z3PrYyLVdvRDc9cT9I3MB9ug...
Run Code Online (Sandbox Code Playgroud)
在本地,网址看起来像:
http://0.0.0.0:8080/_ah/img/encoded_gs_file:Z2lmdF9p...
Run Code Online (Sandbox Code Playgroud)
App Engine错误日志说:
ERROR 2014-12-21 23:12:35,256 blob_download.py:204]无法找到带有编码的编码_s_file文件:Z2lmdF9p ...
难道我做错了什么?文档说在本地提供图像应该在SDK 1.8之后正常工作.如果我无法使其工作,我唯一的解决方案是保留本地托管的所有生产映像(用于开发).
请参阅这个非常好的存储库,它解释了如何在开发 SDK 或生产中将文件保存在 GCS 中。
具体来说,对于你的问题:
# image API supported formats
if file_extension in ['jpeg', 'jpg', 'png', 'gif', 'bmp', 'tiff', 'ico']:
# High-performance dynamic image serving
self.serving_url = images.get_serving_url(self.blobkey, secure_url=True)
elif os.environ['SERVER_SOFTWARE'].startswith('Development'):
# GCS url: this SDK feature has not been documented yet !!!
self.serving_url = '/_ah/gcs%s' % self.gcs_filename
else:
# GCS url: because of HTTPS we cannot use a cname redirect or use the use_blobstore option
self.serving_url = 'https://storage.googleapis.com%s' % self.gcs_filename
Run Code Online (Sandbox Code Playgroud)
感谢@voscausa。
| 归档时间: |
|
| 查看次数: |
957 次 |
| 最近记录: |