在Firebase中执行文件写入功能时出现EROFS错误 [英] EROFS error when executing a File Write function in Firebase

查看:61
本文介绍了在Firebase中执行文件写入功能时出现EROFS错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Firebase托管了我的网站.但是,我被困住了.

I have hosted my website using Firebase. However, I am stuck.

我的想法是创建一个用户页面.当用户单击创建我的页面"时,我希望创建一个新页面,其中将包含有关用户的详细信息.用户可以将新页面的URL共享给他的朋友,他的朋友应该可以看到他的数据.

My idea is to create a user page. When the user clicks "create my page" I want a new page to be created which will hold details about the user. The user can share the URL of the new page to his friends and his friends should be able to see his data.

我尝试在节点js中使用fs模块,以便使用云功能编写其他页面.在本地主机上运行时,这种读取数据,写入数据然后将其呈现给用户的方法非常好.但是,在部署网站之后,执行该功能时,它将引发一条错误消息,指出"EROFS:只读文件系统".

I tried using the fs module in node js in order to write an additional page using cloud functions. This method of reading data, writing it, and then rendering it back to the user works perfectly fine when it is run on the localhost. However, after deploying the website, when the function is executed, it throws an error message stating " EROFS: read-only file system".

请提出解决此错误的方法.

Please suggest ways to deal with this error.

推荐答案

Node的fs模块仅用于写入本地文件系统.由于您使用的是Firebase功能,因此FS的唯一可写部分是/tmp,如所述这里.如果您要写入Cloud Storage,因为您需要保留这些文件,则必须使用 Admin SDK ,包装了Cloud Storage SDK).

Node's fs module is only for writing the local filesystem. Since you are using Firebase Functions, the only writable part of the FS is /tmp as mentioned here. If you want to write to Cloud Storage instead since you need to persist these files, you're going to have to use the Cloud Storage SDK (or the Admin SDK, which wraps the Cloud Storage SDK).

这篇关于在Firebase中执行文件写入功能时出现EROFS错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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