Skip to content

FTP

The Ftp module enables reading and writing files on ftp servers.

The common parameters for all Ftp methods are;

  • url the url to the file to do the action on
  • opts options, an object which may contain the following properties:
    • user username for the ftp server, blank if anonymous access is allowed
    • pass password for the ftp server

Read

Read a file using the read method.

javascript
// Anonymous
var data = Ftp.read("ftp://somewhere/over/the/rainbow.txt", {});
// With user/pass
var data = Ftp.read("ftp://somewhere/over/the/rainbow.txt", { 'user': 'John', 'pass': 'ramb0' });

Write

Write a file to a remote ftp server.

Has the additional data parameter.

  • url the url to the file to write
  • data the content of the file
  • opts options, an object which may contain the following properties:
    • user username for the ftp server, blank if anonymous access is allowed
    • pass password for the ftp server
javascript
Ftp.write("ftp://somewhere/over/the/rainbow.txt", "red, green, blue", {});

Upload

Upload a file from disk using the Ftp.upload method:

js
Ftp.upload("http://save.my/file", "C:\\here\\is\\my\\file.txt");

Download

Download a file using .download.

js
Ftp.download("http://download.me/file.txt", "C:\\here\\is\\my\\file.txt");

List

List the contents of a remote dir.

js
var result = Ftp.ls("http://some.remote/dir");

Create directory

Create a new remote dir.

js
Ftp.mkdir("http://some.remote/dir");

Delete directory

Delete a remote dir.

js
Ftp.rmdir("http://some.remote/dir");

Delete a file

Delete an existing file.

js
Ftp.rm("http://some.remote/dir.txt");