FTP protocol
This protocol allows the application to read or write a file using the file transfer protocol (ftp).
Summary
- Name
-
ftp - Description
- Reads or writes a remote file using the file transfer protocol.
- Resource name
- Can contain the URL of remote resource, using
ftp:protocol, or can be overriden using the protocol configuration parameters. - Operations
-
GET- read file contents. -
PUT- create or replace file contents.
The ftp protocol implementation in zero.core
uses java.net.URLConnection for ftp: URLs.
Request and response format
GET operation
Request headers
| Request header name | Comments |
|---|---|
Content-Type |
Optional file contents MIME type and charset. |
If a Content-Type header is supplied, the value will be associated with the response.
By supplying a Content-Type value containing a charset parameter, you can control the character
encoding the connection infrastructure will use if it is necessary to convert the response body from binary to character
data. If no charset value is available, the system character encoding will be assumed.
Request body
No request body.
Response headers
| Response header name | Comments |
|---|---|
Content-Type |
Value specified in request header, if supplied. |
Response body
The response body is an InputStream containing contents of file.
PUT operation
Request headers
| Request header name | Comments |
|---|---|
Content-Type |
Optional file contents MIME type and charset. |
Request body
| Request body type | Comments |
|---|---|
String or Reader |
Converted to binary data according to charset encoding in Content-Type header.
If no Content-Type was specified the system character encoding will be used. |
byte[] or InputStream |
Binary data written to file, without conversion. |
| Other types | Converted to String using toString() and processed as above. |
The file protocol also supports applications using Connection.getRequestOutputStream() without
additional buffering of the request body.
Response headers
| Response header name | Comments |
|---|---|
Content-Type |
Value specified in request header, if supplied. |
Response body
No response body.
Configuration
| Parameter | Description | Default |
|---|---|---|
hostname |
Specifies the FTP server host name,
overriding any ftp: URL value in the target resource name.
Required if path is specified. |
Host name from target resource URL. |
port |
If hostname is specified, then port specifies the network port for the FTP connection.
Ignored if hostname is not specified. |
21 |
path |
Specifies file path on FTP server. Required if hostname is specified. |
File path from target resource URL. |
userid |
User ID for authentication with server. | None. |
password |
Password for authentication with server. (XOR strings are supported) | None. |
type |
File transfer type. | binary |
Values for the userid, password and type configuration parameters
can be also included in target resource URLs following the standard form,
ftp://userid:password@hostname:port/filePath@type=shortTypeValue
.
If any of these protocol configuration parameters is specified, it will replace any equivalent value in the resource
URL.
The type configuration parameter can be set to the following values:
| Type value | Short value | Description |
|---|---|---|
binary |
i |
Binary transfer mode.
This is the default type value. |
text |
a |
Text transfer mode. |
Protocol configuration can be applied to the connection request using various mechanisms, as described in Configuring protocols.