在Blobstore中存储静态图像 [英] storing static images in the blobstore

查看:76
本文介绍了在Blobstore中存储静态图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常在app-engine上托管网站,我可以将所有图像文件放在一个静态目录中,例如img,然后在yaml文件中包含

Normally to host a website on app-engine, I can put all my image files in a static directory, say img, and then in the yaml file have

  • 网址:/img static_dir:img
  • url: /img static_dir: img

当图片要显示在我的网站本身中时,这种用法很有意义.

Such a usage makes sense when the images are for displaying in my website itself.

但是现在我有了一个端点api.就我而言,我需要在后端存储一些图像以供用户访问.与其将它们放在静态目录中,不如将它们放在blobstore中,并使用blob服务url为它们提供服务.有没有一种方法可以将映像部署到Blob存储区,然后获取提供的网址?

But now I have an endpoint api. For my case, I need to store some images in my backend for my users to access. Instead of putting them in static directory, I want to put them in the blobstore and use blob serving url to serve them. Is there a way to deploy images to the blobstore and then get the serving urls?

推荐答案

您可以实施一项任务,检查文件是否在blobstore中,如果没有,则将其上载到blobstore.然后,您可以在cron中运行此任务,也可以将其作为预热任务.

You could implement a task that checks if the files are in the blobstore or not, and if not, uploads them to the blobstore. Then you can run this task in cron or as a warmup task.

仍然,最好使用静态Web服务并从静态存储中提取HTTP中的静态文件.它的性能将比blobstore更好(实际上,它的性能比大多数静态Web托管要好得多),而且成本更低.

Still, it will be best for you to use the static web serving and pull the static files in HTTP from the static storage. It will perform much better than blobstore (in fact, it performs much better than most static web hosting), and will cost you less.

这篇关于在Blobstore中存储静态图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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