Node.js wrapper for smbclient
Requires Node.js 10+
Smbclient must be installed. This can be installed on Ubuntu with sudo apt-get install smbclient
.
const SambaClient = require('samba-client');
let client = new SambaClient({
address: '//server/folder', // required
username: 'test', // not required, defaults to guest
password: 'test', // not required
domain: 'WORKGROUP' // not required
maxProtocol: 'SMB3' // not required
});
// send a file
await client.sendFile('somePath/file', 'destinationFolder/name');
// get a file
await client.getFile('someRemotePath/file', 'destinationFolder/name');
// create a folder
await client.mkdir('folder/tree', (optional) 'current/working/directory');
// By default CWD is __dirname
// executes dir command in remote directory
await client.dir('remote/folder', (optional) 'current/working/directory');
// By default CWD is __dirname
// validate if file or folder exists in the remote device
await client.fileExists('remote/file', (optional) 'current/working/directory');
// By default CWD is __dirname
Pass an empty string in the Current Working Directory parameter, for more information see this PR.