Skip to main content

ftp.get(URL)

Creates a new FTP download request object

Availability

Agent

Parameters

Name Type Description
URL String The URL from which to retrieve the file or directory listing

Returns

An httprequest object

Description

This method returns an httprequest object primed to make an FTP GET request. The request isn’t issued until either httprequest.sendsync() or httprequest.sendasync() is called on the returned httprequest object.

The URL may be in any form suitable for FTP, such as "ftp://host:port/path" for anonymous retrieval or "ftp://user:password@host:port/path" where a username and password are required. The URL must start with "ftp:" — ie. it must include the colon. FTPS is not supported.

The response object (returned directly from httprequest.sendsync() or passed into a callback function registered with httprequest.sendasync()) will contain the request status code and, if successful, the required file or directory listing as its body. See either of the ‘send’ methods listed above for information on status code values indicating success or failure (eg. login denied).

Note For a successful transfer, the status code provided in the response will be 226 (see Wikipedia’s ist of FTP return codes).

Example Code

The following agent code snippets use ftp.get() to set up a request to an anonymous FTP server for a known resource. In each snippet, that same request is used to fetch the required file synchronously and asynchronously.