[英]How to serve Files in a Directory from App Engine Standard Python Environment
For a project, our team is using the app engine python environment to host several scripts that are scraping a website to store data in the form of various json files and directories of images. 对于一个项目,我们的团队正在使用App Engine python环境来托管多个脚本,这些脚本正在抓取网站以各种json文件和图像目录的形式存储数据。 We want to expose these directories to a url (Ex: /img/01.jpg in the app engine directory to "sample.appspot.com/img/01.jpg").
我们希望将这些目录显示为url(例如,app引擎目录中的/img/01.jpg为“ sample.appspot.com/img/01.jpg”)。 The reason is that we want to be able to download these files directly to a react-native mobile app using the fetch api.
原因是我们希望能够使用fetch api将这些文件直接下载到react-native移动应用程序。 Is this feasable, efficient, and quick using app engine and how?
使用App Engine可行,高效且快速吗?如何? If not what combination of google cloud services could we use to achieve the same functionality and how?
如果不能,我们可以使用谷歌云服务的哪种组合来实现相同的功能?如何使用?
You could use Google Cloud Storage to store your files: 您可以使用Google云端存储来存储文件:
Once stored they're pretty much static files, so for serving them you have 2 options: 存储后,它们几乎是静态文件,因此要提供它们,您有2个选择:
serve them as static content, directly from GCS, see, for example Serving from Cloud Storage . 直接从GCS将它们用作静态内容,例如,参见从Cloud Storage提供服务 。
I'd suspect this would be faster. 我怀疑这会更快。 Your app's environment doesn't matter, since it's not even involved.
您的应用程序的环境无关紧要,因为它甚至没有涉及。
serve them dynamically, through your app's URLs & handlers, with your app reading them from GCS. 通过您应用的URL和处理程序动态地为它们提供服务,并且您的应用会从GCS中读取它们。 See, for example:
参见,例如:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.