如何从Firebasefunction访问Firebase托pipe文件
我有一个简单的firebase函数,它必须发送一个文件来响应文件在/app/one.html中的请求
我的项目目录结构
blog |____app |____index.html |____one.html |____functions |____index.js
我必须访问one.html并从senFile()发送它
index.js
const functions = require('firebase-functions'); exports.blog = functions.https.onRequest((req, res) => { res.status(200).sendFile('app/one.html'); #here I need something to do });
据我所知, firebase deploy
function只部署function文件夹的内容。 所以,如果你移动/复制你的应用程序文件夹到函数文件夹内,你可以实现你正在做的事情。
blog |____functions |____app |____index.html |____one.html |____index.js
正确地更改path之后,您可以像快速应用程序一样发送文件。
res.sendFile(path.join(__dirname + 'app/one.html'));
- puppeteer page.evaluate querySelectorAll返回空对象
- 使用api.ai和heroku(node.js)的Facebook Messenger Messenger聊天室中的OAuthexception
- React Native + Firebase + Expo版本喜欢三angular形问题
- Firebase提供了一个“0”而不是实际的variables内容
- 如何使控制器等待服务返回一个值,以及如何访问控制器中返回的值?
- 如何从Cloud Function获取Firebase项目名称或ID
- Firebase函数signInWithCustomToken与Node.js一起未定义
- 对所有http请求使用Firebase函数ENOTFOUND
- 如何在Firebase中安排通知和数据库修改?
- Firebase .on('value')代码块不在内部执行云function。 任何build议要解决?
- 从我之前部署的Firebase控制台获取代码