[英]How do I connect to a samba share in nodejs using the smb2 module?
I cannot get this module to connect to my samba server using code similar to the example advised in the documentation: 我无法使用类似于文档中建议的示例的代码来使该模块连接到我的samba服务器:
// My Code...
// load the library
var SMB2 = require('smb2');
// create an SMB2 instance
var smb2Client = new SMB2({share: "\\\\192.168.1.6\\media",
domain: '',
username: 'user_not_shown',
password: 'real_passworn_not_shown',
debug: true,
autoCloseTimeout: 0
});
smb2Client.readdir('Docos\\SMB_Test\\Adult', function(err, data){
if(err) {
console.log("Error (readdir):\n", err);
console.log("data", data);
} else {
console.log("Connection made.");
console.log(data);
}
});
RESPONSE 响应
--request fe534d42400000000000000000007e0000000000000000000000000000000000d2e24ba20000000000000000000000000000000000000000000000000000000024000200010000000000000000000000000000000000000000000000000000000000000002021002 -请求fe534d42400000000000000000007e0000000000000000000000000000000000d2e24ba200000000000000000000000000000000000000000000000000000000240002000100010000000000000000000000000000000000000000000000000000000000000000000000000000000001001001002
Things I have tried: 我尝试过的事情:
Please assist - especially from anyone using this module. 请协助-特别是使用此模块的任何人。
var SMB2 = require('smb2'); // create an SMB2 instance var smb2Client = new SMB2({share: "\\\\\\\\192.168.1.6\\\\media", domain: 'WORKGROUP', username: 'user_not_shown', password: 'real_passworn_not_shown', //debug: true, autoCloseTimeout: 0 }); smb2Client.readdir('Docos\\\\SMB_Test\\\\Adult', function(err, data){ if(err) { console.log("Error (readdir):\\n", err); } else { console.log("Connection made."); for (let i = 0; i < data.length; i++){ console.log(data[i]); } smb2Client.close(); } });
smb2Client.readdir works for me using version "0.2.6" of this module. smb2Client.readdir使用此模块的“ 0.2.6”版本对我有效。 If directory is empty then console.log(data);
如果目录为空,则console.log(data);
on success should return empty list eg []
. 成功的话应该返回空列表,例如[]
。 Suggest checking SMB2 instance create. 建议检查SMB2实例创建。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.