npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

smb-fast

v1.0.0

Published

File upload and download based on SMB2(https://www.npmjs.com/package/@marsaud/smb2)

Downloads

7

Readme

SMB-FAST Client for Node.js

Introduction

File upload and download based on SMB2(https://www.npmjs.com/package/@marsaud/smb2)

Installation

npm install smb-fast

API

newly added: appendFile() & readfileRecursion()

var smb2Client = new SMB2 ( options )

The SMB2 class is the constructor of your SMB2 client.

the parameter options accepts this list of attributes:

  • share (mandatory): the share you want to access
  • domain (mandatory): the domain of which the user is registred
  • username (mandatory): the username of the user that access the share
  • password (mandatory): the password
  • port (optional): default 445, the port of the SMB server
  • packetConcurrency (optional): default 20, the number of simulatanous packet when writting / reading data from the share
  • autoCloseTimeout (optional): default 10000, the timeout in milliseconds before to close the SMB2 session and the socket, if setted to 0 the connection will never be closed unless you do it

Example:

// load the library
var SMB2 = require('smb2');

// create an SMB2 instance
var smb2Client = new SMB2({
  share:'\\\\000.000.000.000\\c$'
, domain:'DOMAIN'
, username:'username'
, password:'password!'
});

smb2Client.readdir ( path, callback )

Asynchronous readdir(3). Reads the contents of a directory. The callback gets two arguments (err, files) where files is an array of the names of the files in the directory excluding '.' and '..'.

Example:

smb2Client.readdir('Windows\\System32', function(err, files){
    if(err) throw err;
    console.log(files);
});

smb2Client.readFile ( filename, [options], callback )

  • filename String
  • options Object
    • encoding String | Null default = null
  • callback Function

Asynchronously reads the entire contents of a file. Example:

smb2Client.readFile('path\\to\\my\\file.txt', function(err, data){
    if(err) throw err;
    console.log(data);
});

The callback is passed two arguments (err, data), where data is the contents of the file.

If no encoding is specified, then the raw buffer is returned.

smb2Client.writeFile ( filename, data, [options], callback )

  • filename String
  • data String | Buffer
  • options Object
    • encoding String | Null default = 'utf8'
  • callback Function

Asynchronously writes data to a file, replacing the file if it already exists. data can be a string or a buffer.

The encoding option is ignored if data is a buffer. It defaults to 'utf8'.

Example:

smb2Client.writeFile('path\\to\\my\\file.txt', 'Hello Node', function (err) {
    if (err) throw err;
    console.log('It\'s saved!');
});

smb2Client.mkdir ( path, [mode], callback )

Asynchronous mkdir(2). No arguments other than a possible exception are given to the completion callback. mode defaults to 0777.

Example:

smb2Client.mkdir('path\\to\\the\\folder', function (err) {
    if (err) throw err;
    console.log('Folder created!');
});

smb2Client.rmdir ( path, callback )

Asynchronous rmdir(2). No arguments other than a possible exception are given to the completion callback.

Example:

smb2Client.rmdir('path\\to\\the\\folder', function (err) {
    if (err) throw err;
    console.log('Folder deleted!');
});

smb2Client.exists ( path, callback )

Test whether or not the given path exists by checking with the file system. Then call the callback argument with either true or false. Example:

smb2Client.exists('path\\to\\my\\file.txt', function (err, exists) {
    if (err) throw err;
    console.log(exists ? "it's there" : "it's not there!");
});

smb2Client.unlink ( path, callback )

Asynchronous unlink(2). No arguments other than a possible exception are given to the completion callback.

smb2Client.unlink('path\\to\\my\\file.txt', function (err) {
    if (err) throw err;
    console.log("file has been deleted");
});

smb2Client.rename ( oldPath, newPath, callback )

Asynchronous rename(2). No arguments other than a possible exception are given to the completion callback.

smb2Client.rename('path\\to\\my\\file.txt', 'new\\path\\to\\my\\new-file-name.txt', function (err) {
    if (err) throw err;
    console.log("file has been renamed");
});

smb2Client.close ( )

This function will close the open connection if opened, it will be called automatically after autoCloseTimeout ms of no SMB2 call on the server.