Copy files from Samba to node.js folder

I need to copy files from Samba share in my application. The paths are in the format smb://host/filename

. How do I do this in nodejs? fs.createReadStream

refuses to open these paths. I need to do this on both Windows and * nix.


source to share

1 answer

Assuming the host is Linux (since you mentioned "samba" and not "MS SMB"), you first need to mount the remote server with smbmount

. This forum post has an overview on how to do this , then you just read the files as if they were local to your server.

Alternatively smbget

allows you to purchase individual files without installing a remote host, but not efficient for a lot of file requests.

Other editing; some example code:

var remoteFile = require('child_process').spawn('smbget', ['--stdout', 'smb://host/filename']);
remoteFile.stdout.on('data', function(chunk) {
    //handle chunk of data
remoteFile.on('exit', function() {
    //file loaded completely, continue doing stuff




All Articles