如何从Cloud Functions for Firebase文件夹中读取证书文件 [英] How to read cert files from Cloud Functions for Firebase Folder

查看:108
本文介绍了如何从Cloud Functions for Firebase文件夹中读取证书文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试读取certs文件夹下的文件,如下所示:

I am trying to read a file under certs folder as shown below:

-functions
 |
--certs
  |
---idp-public-cert.perm

这是我正在使用的代码读取文件:

Here is the code I am using to read the file:

fs.readFileSync(path.join(__ dirname,'certs / idp-public-cert.pem'))

当我运行该函数时,我收到以下错误:

When I run the function, I get the following errors:

Error: ENOENT: no such file or directory, open '/srv/lib/certs/idp-public-cert.pem'

我很感激任何工作人员如何做到这一点。在此先感谢。

I would appreciate any crew on how to do this. Thanks in advance.

推荐答案

只需使用相对路径 certs / idp-public-cert读取文件.PEM 。将相对于已部署的函数文件夹解释所有相对路径。不要尝试构建文件的完整路径,因为您不应该假设代码部署在服务器实例中有效安装的位置。

Just read the file using the relative path certs/idp-public-cert.pem. All relative paths will be interpreted relative to your deployed functions folder. Don't try to build a full path to the file, as you shouldn't assume where your code deployment is effectively mounted in the server instance.

这篇关于如何从Cloud Functions for Firebase文件夹中读取证书文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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