Support for 'fs' node module on apigee?

According to apigee docs understanding-edge-support-nodejs-modules , the 'fs' module is restricted.

Also point is mentioned as, " Node.js scripts may read and write files within '/resources/node' directory, for instance as a temporary scratch area, but there are no guarantees as to how long the files will persist."

So what does that exactly means ?...is it appropriate to use "fs" module or not? for ex. if I am using 'https' module for SSL secure node server, I need to read server's client key and certificate from file. In such cases shall I use "fs"?...or any other alternative is available to achieve this?

Solved Solved
2 3 193
1 ACCEPTED SOLUTION

Not applicable

Hi @Sonali , You can definitely use fs module to read but not to write the files which are in the '/resources/node' directory .

All your resources will be placed under that directory when ever you deploy/redeploy the apiproxy containing the resources .

Pls go through the below links which can help you do what ever you are planning .

https://community.apigee.com/questions/5648/unable-to-set-location-for-jar-files-in-nodejs-app.html //go through all the comments

+ https://www.npmjs.com/package/trireme#tls-ssl-and-https and

https://community.apigee.com/questions/6081/how-do-you-use-client-certificates-when-making-an.html

for connecting to https backend with certs from node . Looks like Dave and Mukunda were unable to get it working and I haven't tried that yet .

It will be great if you can share your observations here once you follow the steps .

View solution in original post

3 REPLIES 3

Not applicable

Hi @Sonali , You can definitely use fs module to read but not to write the files which are in the '/resources/node' directory .

All your resources will be placed under that directory when ever you deploy/redeploy the apiproxy containing the resources .

Pls go through the below links which can help you do what ever you are planning .

https://community.apigee.com/questions/5648/unable-to-set-location-for-jar-files-in-nodejs-app.html //go through all the comments

+ https://www.npmjs.com/package/trireme#tls-ssl-and-https and

https://community.apigee.com/questions/6081/how-do-you-use-client-certificates-when-making-an.html

for connecting to https backend with certs from node . Looks like Dave and Mukunda were unable to get it working and I haven't tried that yet .

It will be great if you can share your observations here once you follow the steps .

Hey Thanks. These links were helpful. I will update once I am done with my Experiment! 🙂

Not applicable

Yes, you may read and write files using fs. Files that are uploaded to the resources/node directory as a part of your proxy may be read from the disk at any time. However, files that are written by your application at runtime must be considered ephemeral and may not exist outside of the context of a request.