"IOError:[Errno 30]只读文件系统"Google App Engine中的错误 [英] "IOError: [Errno 30] Read-only file system" error in Google App Engine

查看:115
本文介绍了"IOError:[Errno 30]只读文件系统"Google App Engine中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Flask中有一个函数,可以进行一些Web抓取并将内容放入HTML文件中.

I have a function in Flask that does some web scraping and puts the content in a HTML file.

@app.route('/something')
def something():
    web_scraping()
    return render_template('myFile.html')

函数 web_scraping 将一些HTML代码输出到 myFile.html ,并且在本地运行时效果很好,但是当我将其放在Google App Engine上时,我得到了错误:

The function web_scraping outputs some HTML code to myFile.html and works great when I run it locally, but when I put it on Google App Engine, I get this error:

IOError: [Errno 30] Read-only file system: 'templates/myFile.html'

推荐答案

为什么我不能写这个文件?

Why can't I write to this file?

由于以下原因,App Engine不支持写入本地文件:您的应用程序的分布式性质.相反,必须持久化应存储在分布式数据存储中.欲了解更多有关信息,请参阅运行时沙箱上的文档

Writing to local files is not supported in App Engine due to the distributed nature of your application. Instead, data which must be persisted should be stored in the distributed datastore. For more information see the documentation on the runtime sandbox

但是,您仍然可以编写文件:

However, you still can writing files:

在App Engine中,您的应用程序已部署的本地文件系统to是不可写的.此行为可确保安全性和应用程序的可扩展性.

In App Engine, the local filesystem that your application is deployed to is not writeable. This behavior ensures the security and scalability of your application.

但是,如果应用程序需要在运行时写入和读取文件,App Engine提供了内置的Google Cloud Storage流包装器允许您使用许多标准的PHP文件系统功能在App Engine PHP应用程序中读写文件.

However, if the application needs to write and read files at runtime, App Engine provides a built-in Google Cloud Storage stream wrapper that allows you to use many of the standard PHP filesystem functions to read and write files in an App Engine PHP app.

这篇关于"IOError:[Errno 30]只读文件系统"Google App Engine中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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