问题
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