Detailed reference of prototypes, properties and methods available in the
Javascript environment of your Helma web applications.

Default properties and methods of the FTP prototype.
To use this optional module, its repository needs to be added to the application, for example by calling app.addRepository('modules/helma/Ftp.js')
helma Ftp(server)
Constructor for FTP client objects, to send and receive files from an FTP server.

    var ftp = new helma.Ftp("ftp.mydomain.com");

parameters

String | server | as String, the address of the FTP Server to connect to

methods

- setReadTimeout(timeout)

- setTimeout(timeout)

- login(username, password)

- binary()

- ascii()

- active()

- passive()

- pwd()

- dir(path)

- mkdir(dir)

- rmdir(dir)

- cd(dir)

- lcd(dir)

- putFile(localFile, remoteFile)

- putString(str, remoteFile, charset)

- putBytes(bytes, remoteFile)

- getFile(remoteFile, localFile)

- getString(remoteFile)

- deleteFile(remoteFile)

- renameFile(from, to)

- logout()

Methods
helma.Ftp. setReadTimeout(timeout)
Set the default timeout in milliseconds to use when opening a socket.
parameters

| timeout |

helma.Ftp. setTimeout(timeout)
Sets the timeout in milliseconds to use when reading from the data connection.
parameters

| timeout |

helma.Ftp. login(username, password)
Logs in to the FTP server.
parameters

String | username | as String
String | password | as String

returns

| Boolean true if the login was successful, otherwise false

helma.Ftp. binary()
Sets transfer mode to binary for transmitting images and other non-text files.

    ftp.binary();

helma.Ftp. ascii()
Sets transfer mode to ascii for transmitting text-based data.

    ftp.ascii();

helma.Ftp. active()
Switches the connection to use active mode.

    ftp.active();

helma.Ftp. passive()
Switches the connection to use passive mode.

    ftp.passive();

helma.Ftp. pwd()
Returns the path of the current working directory.

    var remotepath = ftp.pwd();

returns

| String containing the current working directory path

helma.Ftp. dir(path)
Returns a listing of the files contained in a directory on the FTP server.
Lists the files contained in the current working directory or, if an alternative path is specified, the files contained in the specified directory.

    var filelist = ftp.dir();

parameters

String | path | as String, optional alternative directory

returns

| Array containing the list of files in that directory

helma.Ftp. mkdir(dir)
Creates a new directory on the server.
The name of the directory is determined as the function's string parameter. Returns false when an error occured (e.g. due to access restrictions, directory already exists etc.), otherwise true.
parameters

String | dir | as String, the name of the directory to be created

returns

| Boolean true if the directory was successfully created, false if there was an error

helma.Ftp. rmdir(dir)
Deletes a directory on the FTP server.
parameters

String | dir | as String, the name of the directory to be deleted

returns

| Boolean true if the deletion was successful, false otherwise

helma.Ftp. cd(dir)
Changes the working directory on the FTP server.

    ftp.cd("/home/users/fred/www"); // use absolute pathname

    ftp.cd(".."); // change to parent directory

    ftp.cd("images"); // use relative pathname

parameters

String | dir | as String, the path that the remote working directory should be changed to

helma.Ftp. lcd(dir)
Changes the working directory of the local machine when being connected to an FTP server.

    ftp.lcd("/home/users/fred/www"); // use absolute pathname

    ftp.lcd(".."); // change to parent directory

    ftp.lcd("images"); // use relative pathname

parameters

String | dir | as String, the path that the local working directory should be changed to

helma.Ftp. putFile(localFile, remoteFile)
Transfers a file from the local file system to the remote server.
Returns true if the transmission was successful, otherwise false.
parameters

String | localFile | as String, the name of the file to be uploaded
String | remoteFile | as String, the name of the remote destination file

returns

| Boolean true if the file was successfully uploaded, false if there was an error

helma.Ftp. putString(str, remoteFile, charset)
Transfers text from a string to a file on the FTP server.

    ftp.putString("Hello, World!", "message.txt");

parameters

String | str | as String, the text content that should be uploaded
String | remoteFile | as String, the name of the remote destination file
String | charset | as String, optional

returns

| Boolean true if the file was successfully uploaded, false if there was an error

helma.Ftp. putBytes(bytes, remoteFile)
Transfers a byte array to a file on the FTP server.
parameters

Array | bytes | The byte array that should be uploaded
String | remoteFile | The name of the remote destination file

returns

| Boolean True if the file was successfully uploaded, false if there was an error

helma.Ftp. getFile(remoteFile, localFile)
Transfers a file from the FTP server to the local file system.

    ftp.getFile(".htaccess", "htaccess.txt");

parameters

String | remoteFile | as String, the name of the file that should be downloaded
String | localFile | as String, the name which the file should be stored under

see

helma.Ftp.cd
helma.Ftp.lcd

helma.Ftp. getString(remoteFile)
Retrieves a file from the FTP server and returns it as string.

    var str = ftp.getString("messages.txt");

parameters

String | remoteFile | as String, the name of the file that should be downloaded

returns

| String containing the data of the downloaded file

see

helma.Ftp.cd

helma.Ftp. deleteFile(remoteFile)
Deletes a file on the FTP server.

    var str = ftp.delete("messages.txt");

parameters

String | remoteFile | as String, the name of the file to be deleted

returns

| Boolean true if the deletion was successful, false otherwise

helma.Ftp. renameFile(from, to)
Renames a file on the FTP server.

    var success = ftp.renameFile("messages.tmp", "messages.txt");

parameters

String | from | the name of the original file
String | to | the new name the original file should get

returns

| Boolean true if renaming the remote file was successful, false otherwise

helma.Ftp. logout()
Terminates the current FTP session.
Tue, 25 Nov 2008 16:50:10 GMT.

### core framework

- global
- app (application)
- req (request)
- res (response)
- session
- path
- root
- HopObject
- User
- File
- FtpClient
- Image
- Mail
- Remote
- Xml
- DatabaseObject
- MimePart
- Skin
- Object

### optional modules

- Array extensions
- Date extensions
- Number extensions
- Object extensions
- String extensions
- HopObject extensions
- global macros
- macro filters
- JSON methods
- helma.Aspects
- helma.Chart
- helma.Color
- helma.Database
- helma.File
- helma.Ftp
- helma.Group
- helma.Html
- helma.Http
- helma.Image
- helma.Mail
- helma.Search
- helma.Skin
- helma.Ssh
- helma.Url
- helma.Zip
- jala.BitTorrent
- jala.Captcha
- jala.Date
- jala.db
- jala.DnsClient
- jala.Form
- jala.History
- jala HopObject extensions
- jala.HtmlDocument
- jala.I18n
- jala.ImageFilter
- jala.IndexManager
- jala.ListRenderer
- jala.Mp3
- jala.PodcastWriter
- jala.RemoteContent
- jala.Rss20Writer
- jala.Utilities
- jala.XmlRpcRequest
- jala.XmlWriter

### java libraries

- browse docjar