-
Notifications
You must be signed in to change notification settings - Fork 3
Name | Type | Description |
---|---|---|
config |
null object |
The ftp connection settings (optional) |
connect |
boolean |
Whether or not to start the connection automatically; default is true; |
- Mixes In:
- Source:
- To Do:
-
- The major functions have been added and this current version
is more stable and geared for asynchronous NodeJS. The following commands need to be added: - Add FTP.stou
- Add FTP.rein
- Add FTP.site
- Add FTP.mode
- Add FTP.acct
- Add FTP.appe
- Add FTP.help
- Add ability to opt into an active port connection for data transfers
FTP extends the NodeJS EventEmitter – see
- The major functions have been added and this current version
-
object
-
array
-
boolean
-
string
-
string
-
string
-
string
-
object
-
array
-
boolean
-
object
-
object
-
object
-
object
processes that would otherwise fail from concurrency.
This function is done automatically when using
the FTP#run method to queue commands.
-
object
Name | Type | Description |
---|---|---|
queue._queue |
array |
Stores registered procedures and holds them until called by the queue.run method |
queue.processing |
boolean |
Returns true if there are items running in the queue |
queue.register |
function |
Registers a new callback function to be triggered after the queued command completes |
queue.run |
function |
If there is something in the queue and queue.processing is false, than the first item stored in queue._queue will be removed from the queue and processed. |
- FTP#event:queueEmpty
-
string
Name | Type | Description |
---|---|---|
nonprint |
string |
|
telnet |
string |
|
asa |
string |
-
object
-
string
Name | Type | Description |
---|---|---|
ascii |
string |
|
binary |
string |
|
ebcdic |
string |
|
local |
string |
ftp will emit a ready event once
the server connection has been established
Name | Type | Description |
---|---|---|
config |
null object |
The ftp connection settings (optional) |
connect |
boolean |
Whether or not to start the connection automatically; default is true; |
- Type
-
object
Name | Type | Description |
---|---|---|
callback |
function |
The callback function to be issued. |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
dirpath |
string |
The directory name to change to. | ||
callback |
function |
The callback function to be issued. | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
to the ftp server and runs an optional callback when logged in
Name | Type | Description |
---|---|---|
callback |
function |
The callback function to be issued. (optional) |
Name | Type | Description |
---|---|---|
sig |
number |
the signal code, if not 0, then socket will be destroyed to force closing |
Name | Type | Description |
---|---|---|
filepath |
string |
The location of the remote file to stat. |
callback |
function |
The callback function to be issued. |
- Type
-
number
//getting a date object from the file modified time
ftp.filemtime(‘foo.js’, function (err, filemtime) {
if (err) {
dbg(err);
} else {
dbg(filemtime);
//1402849093000
var dateObject = new Date(filemtime);
//Sun Jun 15 2014 09:18:13 GMT-0700 (PDT)
}
});
Name | Type | Description |
---|---|---|
filepath |
string |
The location of the remote file to fetch. |
callback |
function |
The callback function to be issued. |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback |
function |
The callback function to be issued. | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback |
function |
The callback function to be issued. | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
//Overriding the ftpimp.init instance method
var FTP = require(‘ftpimp’),
//get connection settings
config = {
host: ‘localhost’,
port: 21,
user: ‘root’,
pass: ‘’
},
ftp,
//override init
MyFTP = function(){
this.init();
};
//override the prototype
MyFTP.prototype = FTP.prototype;
//override the init method
MyFTP.prototype.init = function () {
dbg(’Initializing!’);
ftp.handle = ftp.Handle.create();
ftp.connect();
};
//start new MyFTP instance
ftp = new MyFTP(config);
Name | Type | Description |
---|---|---|
filepath |
string |
The location of the remote file or directory to list. |
callback |
function |
The callback function to be issued. |
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. |
Name | Type | Description |
---|---|---|
dirpath |
string |
The location of the remote directory to list. |
callback |
function |
The callback function to be issued. |
Creates a directory and returns the directory name.
Optionally creates directories recursively.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
dirpath |
string |
The directory name to be created. | ||
callback |
function |
The callback function to be issued. | ||
recursive |
boolean |
Recursively create directories. (default: false) | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Name | Type | Description |
---|---|---|
type |
string |
set to this type: ‘stream’, ‘block’, ‘compressed’ |
- Source:
- To Do:
-
- - This still needs to be added – should create an object of methods
which allows for file transfers
Name | Type | Description |
---|---|---|
callback |
function |
The callback function to be issued |
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pass |
string |
The password for the user. | ||
callback |
function |
The callback function to be issued. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pasv |
string |
The pasv parameter a1,a2,a3,a4,p1,p2 where a1.a2.a3.a4 is the IP address and p1*256+p2 is the port number |
||
callback |
function |
The callback function to be issued. | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback |
function |
The callback function to be issued. | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
port |
string |
The port parameter a1,a2,a3,a4,p1,p2. This is interpreted as IP address a1.a2.a3.a4, port p1*256+p2. |
||
callback |
function |
The callback function to be issued. | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Name | Type | Description |
---|---|---|
paths |
string array |
The path to read and send the file, if you are sending to the same (relative) location you are reading from then you can supply a string as a shortcut. Otherwise, use an array [from, to] |
callback |
function |
The callback function to be issued once the file has been successfully written to the remote |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback |
function |
The callback function to be issued. | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
calls the callback function once data is received
Name | Type | Description |
---|---|---|
command |
string |
The command to send to the FTP server |
callback |
function |
The callback function to be fired once on a data event |
//say hi to the server
var FTP = require(‘ftpimp’),
config = require(‘./myconfig’),
ftp = FTP.connect(config);
ftp.on(‘ready’, function () {
ftp.raw(‘NOOP’, function (data) {
dbg(data);
});
});
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
paths |
array |
The path of the current file and the path you wish to rename it to; eg: [‘from’, ‘to’] |
||
callback |
function |
The callback function to be issued. | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
dirpath |
string |
The location of the directory to be deleted. | ||
callback |
function |
The callback function to be issued. | ||
recursive |
string |
Recursively delete files and subfolders. | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback |
function |
The callback function to be issued. | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Functions created with this provide a sequential queue
that is asynchronous, so items will be processed
in the order they are received, but this will happen
immediately. Meaning, if you make a dozen sequential calls
of “ftp.run(‘MDTM’, callback);” they will all be read immediately,
queued in order, and then processed one after the other. Unless
you set the optional parameter runLevel to true
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
command |
string |
The command that will be issued ie: “CWD foo” | ||
callback |
function |
The callback function to be issued on success/error | ||
runLevel |
number |
<optional> |
0 | TL;DR see Queue.RunLevels FTP#run will invoke a queueing process, callbacks will be stacked to maintain synchronicity. How they stack will depend on the value you set for the runLevel |
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Same as FTP#run except this command will be
will be prioritized to be the next to run in the queue.
- calls made with this provide a sequential queue
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
command |
string |
The command that will be issued ie: “CWD foo” | ||
callback |
function |
The callback function to be issued on success/error | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Same as FTP#run except this command will be ran immediately (in parallel)
and will overrun any current queue action in place.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
command |
string |
The command that will be issued ie: “CWD foo” | ||
callback |
function |
The callback function to be issued on success/error | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
then saves the file locally
Name | Type | Description |
---|---|---|
paths |
string array |
An array of [from, to] paths, as in read from “remote/location/foo.txt” and save to “local/path/bar.txt” if you are saving to the same relative location you are reading from then you can supply a string as a shortcut. |
callback |
function |
The callback function to be issued. |
based on the path provided
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
command |
string |
The command that will be issued | ||
parameters |
string |
The parameters to be passed with the command | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
- Source:
- To Do:
-
- - This still needs to be added – should create an object of methods
Name | Type | Description |
---|---|---|
filepath |
string |
The location of the file to retrieve size from. |
callback |
function |
The callback function to be issued. |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback |
function |
The callback function to be issued. | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
string |
set to this type: ‘ascii’, ‘ebcdic’, ‘binary’, ‘local’ | ||
secondType |
string |
‘nonprint’, ‘telnet’, ‘asa’ | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
filepath |
string |
The location of the file to be deleted. | ||
callback |
function |
The callback function to be issued. | ||
runLevel |
boolean |
execution priority; @see FTP.Queue.RunLevels. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
username |
string |
The name of the user to log in. | ||
callback |
function |
The callback function to be issued. | ||
holdQueue |
boolean |
<optional> |
false | Prevents the queue from firing an endproc event, user must end manually |
of the files successful transfer
- Source:
- fileTransferComplete
- queueEmpty
- error
- ready