Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read cert files from Cloud Functions for Firebase Folder

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.

like image 625
Jerry Okafor Avatar asked Jan 24 '19 22:01

Jerry Okafor


People also ask

What file format should be used when storing function code in a cloud storage bucket?

You need to add the google-cloud-storage package to your requirements. txt file to install it in the Cloud Functions environment.


1 Answers

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.

like image 102
Doug Stevenson Avatar answered Oct 15 '22 17:10

Doug Stevenson