We're using node fs to access Files from NFS Network Drive. While testing locally, it works fine as it tries to access the NFS using my credentials in the background.
When I deploy the same code in cloud, it fails as my credentials are not present.The point is, to access the shared directory, I need to authenticate in the fs part.
So, I am looking for a way to solve this problem by giving credentials upon accessing or any other ways. Somehow I need to supply username/password/domain because this file requires special permission. Is it possible to supply permissions somehow? For example:
var fs = require('fs');
var file = '\\someserver\stuff\names.txt';
var credentials = { username:'mydomain/jsmith', password:'password' }; ???
fs.readFile(file, 'utf8', function(err, data) {
if (err) throw err;
console.log(data);
});
Note: Any solutions apart from mounting pls.
NFS stands for Network File System.
the node built in module
fsalso stands for File System.Usually, to work with a
file systemyou first need to mount it. Not just an FTP server that work with the file system by itself.The npm package node-nfsc first mount it, then allow you to browse.
You didn't explain what is your restriction, and why you want to avoid mounting.
If working with
fsmodule is not a requirement, you can drop a middleware service that will mount the NFS (with all the restriction you need) and provide http\ftp\scp\etc access without any mounting in the node.P.S. The wiki page mention webNFS as a version that allowing to function ... without the complexity of Portmap and MOUNT protocols, but I didn't find any way to use it.