forked from eflexsystems/node-samba-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
55 lines (41 loc) · 1.15 KB
/
example.js
File metadata and controls
55 lines (41 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
var fs = require('fs');
var SambaClient = require('./');
var testFile = 'test.txt';
fs.writeFileSync(testFile, testFile);
var client = new SambaClient({
address: process.argv[2],
username: 'Guest'
});
client.mkdir('test-directory', function(err) {
if (err) {
return console.error(err);
}
console.log('created test directory on samba share at ' + client.address);
});
client.sendFile(testFile, testFile, function(err) {
if (err) {
return console.error(err);
}
console.log('sent test file to samba share at ' + client.address);
fs.unlinkSync(testFile);
client.getFile(testFile, testFile, function(err) {
if (err) {
return console.error(err);
}
console.log('got test file from samba share at ' + client.address);
});
client.fileExists(testFile, function(err, exists) {
if (err) {
return console.error(err);
}
if (exists) {
console.log('test file exists on samba share at ' + client.address);
} else {
console.log('test file does not exist on samba share at ' + client.address);
}
});
});
process.on('exit', function() {
fs.unlinkSync(testFile);
});