Installations
npm install @icetee/ftp
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=6.4.0
Node Version
10.15.3
NPM Version
6.14.8
Score
93.9
Supply Chain
99.6
Quality
75.7
Maintenance
100
Vulnerability
100
License
Releases
Fixes keepalive bug
Published on 22 Aug 2020
Fix npm Bump
Published on 31 Jan 2020
Fix reentry is not defined
Published on 31 Jan 2020
No waiting for 266 or 250 transfer anymore
Published on 23 Dec 2019
Fix four-digit year MSDOS
Published on 23 Aug 2018
Expanded RegExp
Published on 16 Jun 2018
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
icetee
Download Statistics
Total Downloads
8,048,545
Last Day
3,625
Last Week
35,545
Last Month
192,893
Last Year
2,081,886
GitHub Statistics
25 Stars
247 Commits
16 Forks
5 Watching
5 Branches
1 Contributors
Package Meta Information
Latest Version
1.0.8
Package Id
@icetee/ftp@1.0.8
Size
18.89 kB
NPM Version
6.14.8
Node Version
10.15.3
Publised On
22 Aug 2020
Total Downloads
Cumulative downloads
Total Downloads
8,048,545
Last day
-60%
3,625
Compared to previous day
Last week
-30.3%
35,545
Compared to previous week
Last month
-2.2%
192,893
Compared to previous month
Last year
50.2%
2,081,886
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Description
node-ftp is an FTP client module for node.js that provides an asynchronous interface for communicating with an FTP server.
Requirements
- node.js -- v6.4.0 or newer
Install
npm install ftp
Examples
- Get a directory listing of the current (remote) working directory:
1 var Client = require('ftp'); 2 3 var c = new Client(); 4 c.on('ready', function() { 5 c.list(function(err, list) { 6 if (err) throw err; 7 console.dir(list); 8 c.end(); 9 }); 10 }); 11 // connect to localhost:21 as anonymous 12 c.connect();
- Download remote file 'foo.txt' and save it to the local file system:
1 var Client = require('ftp'); 2 var fs = require('fs'); 3 4 var c = new Client(); 5 c.on('ready', function() { 6 c.get('foo.txt', function(err, stream) { 7 if (err) throw err; 8 stream.once('close', function() { c.end(); }); 9 stream.pipe(fs.createWriteStream('foo.local-copy.txt')); 10 }); 11 }); 12 // connect to localhost:21 as anonymous 13 c.connect();
- Upload local file 'foo.txt' to the server:
1 var Client = require('ftp'); 2 var fs = require('fs'); 3 4 var c = new Client(); 5 c.on('ready', function() { 6 c.put('foo.txt', 'foo.remote-copy.txt', function(err) { 7 if (err) throw err; 8 c.end(); 9 }); 10 }); 11 // connect to localhost:21 as anonymous 12 c.connect();
API
Events
-
greeting(< string >msg) - Emitted after connection.
msg
is the text the server sent upon connection. -
ready() - Emitted when connection and authentication were sucessful.
-
close(< boolean >hadErr) - Emitted when the connection has fully closed.
-
end() - Emitted when the connection has ended.
-
error(< Error >err) - Emitted when an error occurs. In case of protocol-level errors,
err
contains a 'code' property that references the related 3-digit FTP response code.
Methods
* Note: As with the 'error' event, any error objects passed to callbacks will have a 'code' property for protocol-level errors.
-
(constructor)() - Creates and returns a new FTP client instance.
-
connect(< object >config) - (void) - Connects to an FTP server. Valid config properties:
-
host - string - The hostname or IP address of the FTP server. Default: 'localhost'
-
port - integer - The port of the FTP server. Default: 21
-
secure - mixed - Set to true for both control and data connection encryption, 'control' for control connection encryption only, or 'implicit' for implicitly encrypted control connection (this mode is deprecated in modern times, but usually uses port 990) Default: false
-
secureOptions - object - Additional options to be passed to
tls.connect()
. Default: (none) -
user - string - Username for authentication. Default: 'anonymous'
-
password - string - Password for authentication. Default: 'anonymous@'
-
connTimeout - integer - How long (in milliseconds) to wait for the control connection to be established. Default: 10000
-
pasvTimeout - integer - How long (in milliseconds) to wait for a PASV data connection to be established. Default: 10000
-
keepalive - integer - How often (in milliseconds) to send a 'dummy' (NOOP) command to keep the connection alive. Default: 10000
-
-
end() - (void) - Closes the connection to the server after any/all enqueued commands have been executed.
-
destroy() - (void) - Closes the connection to the server immediately.
Required "standard" commands (RFC 959)
-
list([< string >path, ][< boolean >useCompression, ]< function >callback) - (void) - Retrieves the directory listing of
path
.path
defaults to the current working directory.useCompression
defaults to false.callback
has 2 parameters: < Error >err, < array >list.list
is an array of objects with these properties:* type - _string_ - A single character denoting the entry type: 'd' for directory, '-' for file (or 'l' for symlink on **\*NIX only**). * name - _string_ - The name of the entry. * size - _string_ - The size of the entry in bytes. * date - _Date_ - The last modified date of the entry. * rights - _object_ - The various permissions for this entry **(*NIX only)**. * user - _string_ - An empty string or any combination of 'r', 'w', 'x'. * group - _string_ - An empty string or any combination of 'r', 'w', 'x'. * other - _string_ - An empty string or any combination of 'r', 'w', 'x'. * owner - _string_ - The user name or ID that this entry belongs to **(*NIX only)**. * group - _string_ - The group name or ID that this entry belongs to **(*NIX only)**. * target - _string_ - For symlink entries, this is the symlink's target **(*NIX only)**. * sticky - _boolean_ - True if the sticky bit is set for this entry **(*NIX only)**.
-
get(< string >path, [< boolean >useCompression, ]< function >callback) - (void) - Retrieves a file at
path
from the server.useCompression
defaults to false.callback
has 2 parameters: < Error >err, < ReadableStream >fileStream. -
put(< mixed >input, < string >destPath, [< boolean >useCompression, ]< function >callback) - (void) - Sends data to the server to be stored as
destPath
.input
can be a ReadableStream, a Buffer, or a path to a local file.useCompression
defaults to false.callback
has 1 parameter: < Error >err. -
append(< mixed >input, < string >destPath, [< boolean >useCompression, ]< function >callback) - (void) - Same as put(), except if
destPath
already exists, it will be appended to instead of overwritten. -
rename(< string >oldPath, < string >newPath, < function >callback) - (void) - Renames
oldPath
tonewPath
on the server.callback
has 1 parameter: < Error >err. -
logout(< function >callback) - (void) - Logout the user from the server.
callback
has 1 parameter: < Error >err. -
delete(< string >path, < function >callback) - (void) - Deletes a file,
path
, on the server.callback
has 1 parameter: < Error >err. -
cwd(< string >path, < function >callback) - (void) - Changes the current working directory to
path
.callback
has 2 parameters: < Error >err, < string >currentDir. Note:currentDir
is only given if the server replies with the path in the response text. -
abort(< function >callback) - (void) - Aborts the current data transfer (e.g. from get(), put(), or list()).
callback
has 1 parameter: < Error >err. -
site(< string >command, < function >callback) - (void) - Sends
command
(e.g. 'CHMOD 755 foo', 'QUOTA') using SITE.callback
has 3 parameters: < Error >err, < _string >responseText, < integer >responseCode. -
status(< function >callback) - (void) - Retrieves human-readable information about the server's status.
callback
has 2 parameters: < Error >err, < string >status. -
ascii(< function >callback) - (void) - Sets the transfer data type to ASCII.
callback
has 1 parameter: < Error >err. -
binary(< function >callback) - (void) - Sets the transfer data type to binary (default at time of connection).
callback
has 1 parameter: < Error >err.
Optional "standard" commands (RFC 959)
-
mkdir(< string >path, [< boolean >recursive, ]< function >callback) - (void) - Creates a new directory,
path
, on the server.recursive
is for enabling a 'mkdir -p' algorithm and defaults to false.callback
has 1 parameter: < Error >err. -
rmdir(< string >path, [< boolean >recursive, ]< function >callback) - (void) - Removes a directory,
path
, on the server. Ifrecursive
, this call will delete the contents of the directory if it is not empty.callback
has 1 parameter: < Error >err. -
cdup(< function >callback) - (void) - Changes the working directory to the parent of the current directory.
callback
has 1 parameter: < Error >err. -
pwd(< function >callback) - (void) - Retrieves the current working directory.
callback
has 2 parameters: < Error >err, < string >cwd. -
system(< function >callback) - (void) - Retrieves the server's operating system.
callback
has 2 parameters: < Error >err, < string >OS. -
listSafe([< string >path, ][< boolean >useCompression, ]< function >callback) - (void) - Similar to list(), except the directory is temporarily changed to
path
to retrieve the directory listing. This is useful for servers that do not handle characters like spaces and quotes in directory names well for the LIST command. This function is "optional" because it relies on pwd() being available.
Extended commands (RFC 3659)
-
size(< string >path, < function >callback) - (void) - Retrieves the size of
path
.callback
has 2 parameters: < Error >err, < integer >numBytes. -
lastMod(< string >path, < function >callback) - (void) - Retrieves the last modified date and time for
path
.callback
has 2 parameters: < Error >err, < Date >lastModified. -
restart(< integer >byteOffset, < function >callback) - (void) - Sets the file byte offset for the next file transfer action (get/put) to
byteOffset
.callback
has 1 parameter: < Error >err. -
mlsd([< string >path, ][< boolean >useCompression, ]< function >callback) - (void) - Retrieves the directory listing of
path
.path
defaults to the current working directory.useCompression
defaults to false.callback
has 2 parameters: < Error >err, < array >list. See thelist
command for a list of properties. Also see https://tools.ietf.org/html/rfc3659 7.2.
Draft commands (draft-somers-ftp-mfxx-04)
- setLastMod(< string >path, < Date >date, < function >callback) - (void) - Set modification time for
path
.callback
has 1 parameter: < Error >err.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 2/28 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 4 are checked with a SAST tool
Score
3
/10
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More