How to read cert files from Cloud Functions for Firebase Folder

我们两清 提交于 2020-01-14 13:25:30

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/54356603/how-to-read-cert-files-from-cloud-functions-for-firebase-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!