There can be another way to find the contents in the directory which is using smb2 module.
As network drive requires user credentials to access its contents therefore it is returning null. Also if we try to access it using file system of Node js then it may also return access denied.
So to access the contents of network location we can use external node library i.e SMB2
An example for the same can be -
var smb2 = require('smb2');
var epConfig = {
smb2PdfGenerateConfig: {
share: '\\\\10.10.1.6'
, domain: 'domain'
, username: 'username'
, debug: false
, password: 'password!'
, autoCloseTimeout: 0
}
}
var smb2Client = new smb2({
share: epConfig.smb2PdfGenerateConfig.share,
domain: epConfig.smb2PdfGenerateConfig.domain,
username: epConfig.smb2PdfGenerateConfig.username,
password: epConfig.smb2PdfGenerateConfig.password,
debug: epConfig.smb2PdfGenerateConfig.debug,
autoCloseTimeout: epConfig.smb2PdfGenerateConfig.autoCloseTimeout
});
smb2Client.readdir('Images', function(err, files){
if(err) console.log("err",err);
else{
for(var i=0; i<files.length; i++) {
console.log("file",files[i]);
}
}
});