将静态图像存储在blobstore中

时间:2021-02-20 23:10:55

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

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

  • url: /img static_dir: img
  • url:/ img static_dir:img

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

当图像用于在我的网站本身中显示时,这种用法是有意义的。

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?

但现在我有一个端点api。对于我的情况,我需要在我的后端存储一些图像供我的用户访问。我想将它们放在blobstore中并使用blob服务url来提供它们,而不是将它们放在静态目录中。有没有办法将图像部署到blobstore然后获取服务URL?

1 个解决方案

#1


0  

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.

您可以实现检查文件是否在blobstore中的任务,如果不是,则将它们上载到blobstore。然后,您可以在cron中运行此任务或作为预热任务。

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.

尽管如此,最好使用静态Web服务并从静态存储中提取HTTP中的静态文件。它的性能要比blobstore好得多(事实上,它的性能比大多数静态虚拟主机要好得多),并且会降低成本。

#1


0  

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.

您可以实现检查文件是否在blobstore中的任务,如果不是,则将它们上载到blobstore。然后,您可以在cron中运行此任务或作为预热任务。

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.

尽管如此,最好使用静态Web服务并从静态存储中提取HTTP中的静态文件。它的性能要比blobstore好得多(事实上,它的性能比大多数静态虚拟主机要好得多),并且会降低成本。