13

The path looks like this

\\10.1.10.11\Results\\filename.rtf

From my machine, i can access it just fine by pasting it to Run box, enter username and password.

I've tried smb2 (smb2) but the sample code just hangs and after awhile, I get Error: read ECONNRESET.

I need to make this works on both linux and windows.

Tuan Anh Tran
  • 6,807
  • 6
  • 37
  • 54

3 Answers3

22

Did you escape the backslashes?

 var path = "\\\\10.1.10.11\\Results\\filename.rtf";
 console.log(path);

Above works, but here's a better looking way (that accomplishes the same path without having to double up those backslashes):

let path = String.raw`\\10.1.10.11\Results\filename.rtf`;
console.log(path);

Warning: With this technique, you still have to double up the backslash if the string ends with a backslash.

Doing this, I just had success attaching a file (located on a network share) to an email via node.js (and the nodemailer package). Perhaps this would apply in what you're doing too.

Lonnie Best
  • 9,936
  • 10
  • 57
  • 97
3

I figure I might as well just mount it and access it like local file.

for Linux server, I used smbmount.

Tuan Anh Tran
  • 6,807
  • 6
  • 37
  • 54
3

In Ubuntu try the cifs-utils package to mount the smb-cifs Windows file share to a Linux mount path

sudo apt-get install cifs-utils
mount -t cifs -o username=USERNAME,password=PASSWD //192.168.1.88/shares /mnt/share

and then you can access it in this directory: /mnt/share

In Windows you should be able to access the network path directly. Windows 7 seems to accept forward slashes in place of back slashes for a network path name. Try this:

var path = "//10.1.10.11/Results/filename.rtf";
steampowered
  • 11,809
  • 12
  • 78
  • 98