简体   繁体   English

如何通过App Engine标准Python环境在目录中提供文件

[英]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.

相关问题 如何在Google App Engine标准环境(manage.py,…)中运行文件Django / python我的文件 - How to run files my files Django/python in Google App Engine Standard Environment ( manage.py, … ) Google App Engine标准环境(Python + SAML) - Google App Engine Standard Environment (Python + SAML) App Engine 标准 Python 3 环境变量未定义 - App Engine Standard Python 3 environment variables undefined 如何在谷歌应用引擎上提供静态文件 - how to serve static files on google app engine Google Cloud App Engine:如何在灵活的环境中提供https - Google Cloud App Engine: How to serve https in a Flexible environment 您可以从 App Engine 标准环境运行 Python 模块子流程吗? - Can you run the Python module Subprocess from App Engine standard environment? App Engine Python,标准环境,使用 time.sleep - App Engine Python, Standard Environment, using time.sleep 如何使用App Engine上的Python标准环境连接到Cloud SQL上的Postgres - How to connect to Postgres on Cloud SQL using the Python Standard Environment on App Engine 是否可以从App Engine标准环境访问Google Pub / Sub? - Access Google Pub/Sub from App Engine standard environment? 如何从Dockerized Python Web应用程序提供静态文件? - How to serve static files from a Dockerized Python web app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM