ftp

v1.2.4

FTP Release Notes

Ftp 1.2.4

Improvements and New Features

The license and copyright header has changed format to include an SPDX-License-Identifier. At the same time, most files have been updated to follow a uniform standard for license headers.

Own Id: OTP-19575 Aux Id: PR-9670

Ftp 1.2.3

Fixed Bugs and Malfunctions

Eliminated a race condition that sometimes resulted in ftp:recv_bin/2 returning ok instead of {ok, Data}.

Own Id: OTP-19119 Aux Id: GH-8454 ,PR-8543

Ftp 1.2.2

Fixed Bugs and Malfunctions

Dialyzer warnings due to type specs added in dbg have been eliminated.

Own Id: OTP-18860

Improvements and New Features

The documentation has been migrated to use Markdown and ExDoc.

Own Id: OTP-18955 Aux Id: PR-8026

Ftp 1.2.1.1

Fixed Bugs and Malfunctions

Fix race condition that sometimes resulted in ftp:recv_bin/2 returning ok instead of {ok, Data}.

Own Id: OTP-19119 Aux Id: GH-8454 ,PR-8543

Ftp 1.2.1

Fixed Bugs and Malfunctions

Replaced unintentional Erlang Public License 1.1 headers in some files with the intended Apache License 2.0 header.

Own Id: OTP-18815 Aux Id: PR-7780

Ftp 1.2

Fixed Bugs and Malfunctions

Fixes the documentation for the ftp module and updates the typing of ftp functions that return errors.

The documentation has been improved and the types of the functions are now read from source code, instead of being hard-coded in XML.

Functions returning errors of the form {error, Reason :: 'ehost' | ...} are now similar to other modules, i.e., {error, Reason :: term()}. If one wants to understand the error, one must call the function ftp:formaterror({error, Reason}).

Own Id: OTP-18359 Aux Id: PR-6545

Improvements and New Features

Deprecates dbg:stop_clear/0 because it is simply a function alias to dbg:stop/0

Own Id: OTP-18478 Aux Id: GH-6903

Remove deprecated functions in OTP-26

Own Id: OTP-18541

Ftp 1.1.4

Improvements and New Features

Replace size/1 with either tuple_size/1 or byte_size/1

The size/1 BIF is not optimized by the JIT, and its use can result in worse types for Dialyzer.

When one knows that the value being tested must be a tuple, tuple_size/1 should always be preferred.

When one knows that the value being tested must be a binary, byte_size/1 should be preferred. However, byte_size/1 also accepts a bitstring (rounding up size to a whole number of bytes), so one must make sure that the call to byte_size/ is preceded by a call to is_binary/1 to ensure that bitstrings are rejected. Note that the compiler removes redundant calls to is_binary/1, so if one is not sure whether previous code had made sure that the argument is a binary, it does not harm to add an is_binary/1 test immediately before the call to byte_size/1.

Own Id: OTP-18432 Aux Id: GH-6672,PR-6793,PR-6784,PR-6787,PR-6785,PR-6682,PR-6800,PR-6797,PR-6798,PR-6799,PR-6796,PR-6813,PR-6671,PR-6673,PR-6684,PR-6694,GH-6677,PR-6696,PR-6670,PR-6674

Ftp 1.1.3

Fixed Bugs and Malfunctions

Fixes calls to ftp:nlist/2 returning {error, epath} when the file / folder exists

Own Id: OTP-18409 Aux Id: PR-6721,ERIERL-908

Ftp 1.1.2

Fixed Bugs and Malfunctions

fix unexpected result ok when calling ftp:nlist repeatedly

Own Id: OTP-18252 Aux Id: GH-5823

Ftp 1.1.1

Fixed Bugs and Malfunctions

An unexpected timeout message on the FTP control channel was observed in a real system and could not be associated with anything that was expected to happen, so we will ignore but info log such unexpected messages.

Own Id: OTP-17989 Aux Id: ERIERL-767

Ftp 1.1

Fixed Bugs and Malfunctions

Use OTP supervisor as intended, avoiding surprising behavior as the killing of the user's process. Also, FTP state handling logic is improved to avoid race conditions that could result in unexpected errors.

Own Id: OTP-16926 Aux Id: ERL-1450, GH-4473

Missing runtime dependencies has been added to this application.

Own Id: OTP-17243 Aux Id: PR-4557

Improvements and New Features

Add support for FTPES (explicit FTP over TLS).

Own Id: OTP-15523 Aux Id: OTP-15352, PR-1968

Ftp 1.0.5

Fixed Bugs and Malfunctions

Avoid timing issue when setting active once on a socket that is being closed by the peer.

Own Id: OTP-16734 Aux Id: OTP-16697, ERIERL-496

Ftp 1.0.4.1

Fixed Bugs and Malfunctions

Avoid timing issue when setting active once on a socket that is being closed by the peer.

Own Id: OTP-16734 Aux Id: OTP-16697, ERIERL-496

Ftp 1.0.4

Fixed Bugs and Malfunctions

A possibly infinite loop is removed.

Own Id: OTP-16243 Aux Id: PR-2436, OTP-16056

Improvements and New Features

Removed compiler warnings.

Own Id: OTP-16318 Aux Id: OTP-16183

Ftp 1.0.3

Fixed Bugs and Malfunctions

A possibly infinite loop when receiving messages divided in parts is removed.

Own Id: OTP-16056

Ftp 1.0.2.2

Fixed Bugs and Malfunctions

A possibly infinite loop is removed.

Own Id: OTP-16243 Aux Id: PR-2436, OTP-16056

Ftp 1.0.2.1

Fixed Bugs and Malfunctions

A possibly infinite loop when receiving messages divided in parts is removed.

Own Id: OTP-16056

Ftp 1.0.2

Fixed Bugs and Malfunctions

Fixed timing related bug that could make ftp functions behave badly.

Own Id: OTP-15659 Aux Id: ERIERL-316

Ftp 1.0.1

Fixed Bugs and Malfunctions

Improved documentation.

Own Id: OTP-15190

FTP 1.0

First released version

Inets application was split into multiple smaller protocol specific applications. The FTP application is a standalone FTP client with the same functionality as FTP client in Inets.

Own Id: OTP-14113

FTP client introduction

FTP clients are considered to be rather temporary. Thus, they are only started and stopped during runtime and cannot be started at application startup. The FTP client API is designed to allow some functions to return intermediate results. This implies that only the process that started the FTP client can access it with preserved sane semantics. If the process that started the FTP session dies, the FTP client process terminates.

The client supports IPv6 as long as the underlying mechanisms also do so.

Examples

The following is a simple example of an FTP session, where the user guest with password password logs on to the remote host erlang.org:

      1> ftp:start().
      ok
      2> {ok, Pid} = ftp:open([{host, "erlang.org"}]).
      {ok,<0.22.0>}
      3> ftp:user(Pid, "guest", "password").
      ok
      4> ftp:pwd(Pid).
      {ok, "/home/guest"}
      5> ftp:cd(Pid, "appl/examples").
      ok
      6> ftp:lpwd(Pid).
      {ok, "/home/fred"}.
      7> ftp:lcd(Pid, "/home/eproj/examples").
      ok
      8> ftp:recv(Pid, "appl.erl").
      ok
      9> ftp:close(Pid).
      ok
      10> ftp:stop().
      ok

The file appl.erl is transferred from the remote to the local host. When the session is opened, the current directory at the remote host is /home/guest, and /home/fred at the local host. Before transferring the file, the current local directory is changed to /home/eproj/examples, and the remote directory is set to /home/guest/appl/examples.

ftp

A File Transfer Protocol client.

This module implements a client for file transfer according to a subset of the File Transfer Protocol (FTP), see RFC 959.

The FTP client always tries to use passive FTP mode and only resort to active FTP mode if this fails. This default behavior can be changed by start option mode.

For a simple example of an FTP session, see FTP User's Guide.

The return values of the following functions depend much on the implementation of the FTP server at the remote host. In particular, the results from ls and nlist varies. Often real errors are not reported as errors by ls, even if, for example, a file or directory does not exist. nlist is usually more strict, but some implementations have the peculiar behaviour of responding with an error if the request is a listing of the contents of a directory that exists but is empty.

Errors

The possible error reasons and the corresponding diagnostic strings returned by formaterror/1 are as follows:

echunk - Synchronization error during chunk sending according to one of the following:

A call is made to send_chunk/2 or send_chunk_end/1 before a call to send_chunk_start/2.

A call has been made to another transfer function during chunk sending, that is, before a call to send_chunk_end/1.

eclosed - The session is closed.

econn - Connection to the remote server is prematurely closed.

ehost - Host is not found, FTP server is not found, or connection is rejected by FTP server.

elogin - User is not logged in.

enotbinary - Term is not a binary.

epath - No such file or directory, or directory already exists, or permission denied.

etype - No such type.

euser - Invalid username or password.

etnospc - Insufficient storage space in system [452].

epnospc - Exceeded storage allocation (for current directory or dataset) [552].

efnamena - Filename not allowed [553].

Summary

Types

client()

Chunk File Transfer API

append_chunk(Client, Bin)

Transfers the chunk Bin to the remote server, which appends it to the file specified in the call to append_chunk_start/2.

append_chunk_end(Client)

Stops transfer of chunks for appending to the remote server. The file at the remote server, specified in the call to append_chunk_start/2, is closed by the server.

append_chunk_start(Client, RemoteFile)

Starts the transfer of chunks for appending to the file RemoteFile at the remote server. If the file does not exist, it is created.

recv_chunk(Client)

Receives a chunk of the remote file (RemoteFile of recv_chunk_start). The return values have the following meaning

recv_chunk_start(Pid, RemoteFile)

Starts transfer of the file RemoteFile from the remote server.

send_chunk(Client, Bin)

Transfers the chunk Bin to the remote server, which writes it into the file specified in the call to send_chunk_start/2.

send_chunk_end(Client)

Stops transfer of chunks to the remote server. The file at the remote server, specified in the call to send_chunk_start/2 is closed by the server.

send_chunk_start(Client, RemoteFile)

Starts transfer of chunks into the file RemoteFile at the remote server.

Connection API

account(Client, Acc)

Sets the account for an operation, if needed.

close(Client)

Ends an FTP session, created using function open.

open(Host)

Equivalent to open/2.

open(Host, Opts)

Starts a FTP client process and opens a session with the FTP server at Host.

user(Pid, User, Pass)

Performs login of User with Pass.

user(Pid, User, Pass, Account)

Performs login of User with Pass to the account specified by Account.

File Transfer API

recv(Client, RemoteFileName)

Equivalent to recv/3.

recv(Pid, RemoteFileName, LocalFileName)

Transfers the file RemoteFileName from the remote server to the file system of the local client. If LocalFileName is specified, the local file will be LocalFileName, otherwise RemoteFileName.

recv_bin(Pid, RemoteFile)

Transfers the file RemoteFile from the remote server and receives it as a binary.

send(Client, LocalFileName)

Equivalent to send/3.

send(Pid, LocalFileName, RemoteFileName)

Transfers the file LocalFileName to the remote server. If RemoteFileName is specified, the name of the remote file is set to RemoteFileName, otherwise to LocalFileName.

send_bin(Client, Bin, RemoteFile)

Transfers the binary Bin into the file RemoteFile at the remote server.

Info API

formaterror(Tag)

Given an error return value {error, AtomReason}, this function returns a readable string describing the error.

lpwd(Client)

Returns the current working directory at the local client.

ls(Client)

Equivalent to ls/2.

ls(Client, Dir)

Returns a list of files in long format.

nlist(Client)

Equivalent to nlist/2.

nlist(Client, Pathname)

Returns a list of files in short format.

pwd(Client)

Returns the current working directory at the remote server.

Update API

append(Client, LocalFileName)

Equivalent to append/3.

append(Pid, LocalFileName, RemoteFileName)

Transfers the file LocalFile to the remote server. If RemoteFile is specified, the name of the remote file that the file is appended to is set to RemoteFile, otherwise to LocalFile. If the file does not exists, it is created.

append_bin(Pid, Bin, RemoteFile)

Transfers the binary Bin to the remote server and appends it to the file RemoteFile. If the file does not exist, it is created.

cd(Client, Dir)

Changes the working directory at the remote server to Dir.

delete(Client, File)

Deletes the file File at the remote server.

lcd(Client, Dir)

Changes the working directory to Dir for the local client.

mkdir(Client, Dir)

Creates the directory Dir at the remote server.

rename(Client, Old, New)

Renames Old to New at the remote server.

rmdir(Client, Dir)

Removes directory Dir at the remote server.

type(Client, Type)

Sets the file transfer type to ascii or binary. When an FTP session is opened, the default transfer type of the server is used, most often ascii, which is default according to RFC 959.

Functions

quote(Client, Cmd)

Note

The telnet end of line characters, from the FTP protocol definition, CRLF, for example, "\\r\\n" has been removed.

Types

client()

-type client() :: pid().

Chunk File Transfer API

append_chunk(Client, Bin)

-spec append_chunk(Client :: client(), Bin :: binary()) -> ok | {error, Reason :: term()}.

Transfers the chunk Bin to the remote server, which appends it to the file specified in the call to append_chunk_start/2.

For some errors, for example, file system full, it is necessary to call append_chunk_end to get the proper reason.

append_chunk_end(Client)

-spec append_chunk_end(Client :: client()) -> ok | {error, Reason :: term()}.

Stops transfer of chunks for appending to the remote server. The file at the remote server, specified in the call to append_chunk_start/2, is closed by the server.

append_chunk_start(Client, RemoteFile)

-spec append_chunk_start(Client :: client(), RemoteFile :: string()) -> ok | {error, Reason :: term()}.

Starts the transfer of chunks for appending to the file RemoteFile at the remote server. If the file does not exist, it is created.

recv_chunk(Client)

-spec recv_chunk(Client :: client()) -> ok | {ok, Bin :: binary()} | {error, Reason :: term()}.

Receives a chunk of the remote file (RemoteFile of recv_chunk_start). The return values have the following meaning:

ok = the transfer is complete.

{ok, Bin} = just another chunk of the file.

{error, Reason} = transfer failed.

recv_chunk_start(Pid, RemoteFile)

-spec recv_chunk_start(Pid :: pid(), RemoteFile :: string()) -> ok | {error, Reason :: term()}.

Starts transfer of the file RemoteFile from the remote server.

send_chunk(Client, Bin)

-spec send_chunk(Client :: client(), Bin :: binary()) -> ok | {error, Reason :: term()}.

Transfers the chunk Bin to the remote server, which writes it into the file specified in the call to send_chunk_start/2.

For some errors, for example, file system full, it is necessary to to call send_chunk_end to get the proper reason.

send_chunk_end(Client)

-spec send_chunk_end(Client :: client()) -> ok | {error, Reason :: term()}.

Stops transfer of chunks to the remote server. The file at the remote server, specified in the call to send_chunk_start/2 is closed by the server.

send_chunk_start(Client, RemoteFile)

-spec send_chunk_start(Client :: client(), RemoteFile :: string()) -> ok | {error, Reason :: term()}.

Starts transfer of chunks into the file RemoteFile at the remote server.

Connection API

account(Client, Acc)

-spec account(Client :: client(), Acc :: string()) -> ok | {error, Reason :: term()}.

Sets the account for an operation, if needed.

close(Client)

-spec close(Client :: client()) -> ok.

Ends an FTP session, created using function open.

open(Host)

-spec open(Host :: inet:hostname() | inet:ip_address()) ->
              {ok, Client :: client()} | {error, Reason :: term()}.

Equivalent to open/2.

open(Host, Opts)

-spec open(Host :: string() | inet:ip_address(), Opts) ->
              {ok, Client :: client()} | {error, Reason :: term()}
              when
                  Opts :: [Opt],
                  Opt :: StartOption | OpenOption,
                  StartOption :: {verbose, Verbose} | {debug, Debug},
                  Verbose :: boolean(),
                  Debug :: disable | debug | trace,
                  OpenOption ::
                      {ipfamily, IpFamily} |
                      {port, Port :: port()} |
                      {mode, Mode} |
                      {tls, TLSOptions :: [ssl:tls_option()]} |
                      {tls_sec_method, TLSSecMethod :: ftps | ftpes} |
                      {tls_ctrl_session_reuse, TLSSessionReuse :: boolean()} |
                      {timeout, Timeout :: timeout()} |
                      {dtimeout, DTimeout :: timeout()} |
                      {progress, Progress} |
                      {sock_ctrl, SocketCtrls} |
                      {sock_data_act, [SocketControl]} |
                      {sock_data_pass, [SocketControl]},
                  SocketCtrls :: [SocketControl],
                  IpFamily :: inet | inet6 | inet6fb4,
                  Mode :: active | passive,
                  Module :: atom(),
                  Function :: atom(),
                  InitialData :: term(),
                  Progress :: ignore | {Module, Function, InitialData},
                  SocketControl :: gen_tcp:option().

Starts a FTP client process and opens a session with the FTP server at Host.

A session opened in this way is closed using function close/1.

The available configuration options are as follows:

{host, Host} - Host = string() | ip_address()

{port, Port} - Default is 0 which aliases to 21 or 990 when used with {tls_sec_method,ftps}).

{mode, Mode} - Default is passive.

{verbose, Verbose} - Determines if the FTP communication is to be verbose or not.

Default is false.

{debug, Debug} - Debugging using the dbg toolkit.

Default is disable.

{ipfamily, IpFamily} - With inet6fb4 the client behaves as before, that is, tries to use IPv6, and only if that does not work it uses IPv4).

Default is inet (IPv4).

{timeout, Timeout} - Connection time-out.

Default is 60000 (milliseconds).

{dtimeout, DTimeout} - Data connect time-out. The time the client waits for the server to connect to the data socket.

Default is infinity.

{tls, TLSOptions} - The FTP session is transported over tls (ftps, see RFC 4217). The list TLSOptions can be empty. The function ssl:connect/3 is used for securing both the control connection and the data sessions.

{tls_sec_method, TLSSecMethod} - When set to ftps will connect immediately with SSL instead of upgrading with STARTTLS. This suboption is ignored unless the suboption tls is also set.

Default is ftpes

{tls_ctrl_session_reuse, boolean()} - When set to true the client will re-use the TLS session from the control channel on the data channel as enforced by many FTP servers as (proposed and implemented first by vsftpd).

Default is false.

{sock_ctrl, SocketCtrls :: [SocketControl :: gen_tcp:option()]} - Passes options from SocketCtrls down to the underlying transport layer (tcp).

gen_tcp:option/0 except for ipv6_v6only, active, packet, mode, packet_size and header.

Default value is SocketCtrls = [].

{sock_data_act, [SocketControl]} - Passes options from [SocketControl] down to the underlying transport layer (tcp).

sock_data_act uses the value of sock_ctrl as default value.

{sock_data_pass, [SocketControl]} - Passes options from [SocketControl] down to the underlying transport layer (tcp).

sock_data_pass uses the value of sock_ctrl as default value.

{progress, Progress} - Progress = ignore | {Module, Function, InitialData}

Module = atom(), Function = atom()

InitialData = term()

Default is ignore.

Option progress is intended to be used by applications that want to create some type of progress report, such as a progress bar in a GUI. Default for the progress option is ignore, that is, the option is not used. When the progress option is specified, the following happens when ftp:send/[3,4] or ftp:recv/[3,4] are called:

Before a file is transferred, the following call is made to indicate the start of the file transfer and how large the file is. The return value of the callback function is to be a new value for the UserProgressTerm that will be used as input the next time the callback function is called.

Module:Function(InitialData, File, {file_size, FileSize})

Every time a chunk of bytes is transferred the following call is made:

Module:Function(UserProgressTerm, File, {transfer_size, TransferSize})

At the end of the file the following call is made to indicate the end of the transfer:

Module:Function(UserProgressTerm, File, {transfer_size, 0})

The callback function is to be defined as follows:

Module:Function(UserProgressTerm, File, Size) -> UserProgressTerm

UserProgressTerm = term()

File = string()

Size = {transfer_size, integer()} | {file_size, integer()} | {file_size, unknown}

For remote files, ftp cannot determine the file size in a platform independent way. In this case the size becomes unknown and it is left to the application to determine the size.

Note

The callback is made by a middleman process, hence the file transfer is not affected by the code in the progress callback function. If the callback crashes, this is detected by the FTP connection process, which then prints an info-report and goes on as if the progress option was set to ignore.

The file transfer type is set to the default of the FTP server when the session is opened. This is usually ASCII mode.

The current local working directory (compare lpwd/1) is set to the value reported by file:get_cwd/1, the wanted local directory.

The return value Pid is used as a reference to the newly created FTP client in all other functions, and they are to be called by the process that created the connection. The FTP client process monitors the process that created it and terminates if that process terminates.

user(Pid, User, Pass)

-spec user(Pid :: pid(), User :: string(), Pass :: string()) -> ok | {error, Reason :: term()}.

Performs login of User with Pass.

user(Pid, User, Pass, Account)

-spec user(Pid :: pid(), User :: string(), Pass :: string(), Account :: string()) ->
              ok | {error, Reason :: term()}.

Performs login of User with Pass to the account specified by Account.

File Transfer API

recv(Client, RemoteFileName)

-spec recv(Client :: client(), RemoteFileName :: file:filename()) -> ok | {error, Reason :: term()}.

Equivalent to recv/3.

recv(Pid, RemoteFileName, LocalFileName)

-spec recv(Pid :: pid(), RemoteFileName :: file:filename(), LocalFileName :: file:filename()) ->
              ok | {error, Reason :: term()}.

Transfers the file RemoteFileName from the remote server to the file system of the local client. If LocalFileName is specified, the local file will be LocalFileName, otherwise RemoteFileName.

If the file write fails, the command is aborted and {error, term()} is returned. However, the file is not removed.

recv_bin(Pid, RemoteFile)

-spec recv_bin(Pid :: pid(), RemoteFile :: string()) ->
                  {ok, Bin :: binary()} | {error, Reason :: term()}.

Transfers the file RemoteFile from the remote server and receives it as a binary.

send(Client, LocalFileName)

-spec send(Client :: client(), LocalFileName :: file:filename()) -> ok | {error, Reason :: term()}.

Equivalent to send/3.

send(Pid, LocalFileName, RemoteFileName)

-spec send(Pid :: pid(), LocalFileName :: file:filename(), RemoteFileName :: file:filename()) ->
              ok | {error, Reason :: term()}.

Transfers the file LocalFileName to the remote server. If RemoteFileName is specified, the name of the remote file is set to RemoteFileName, otherwise to LocalFileName.

send_bin(Client, Bin, RemoteFile)

-spec send_bin(Client :: client(), Bin :: binary(), RemoteFile :: string()) ->
                  ok | {error, Reason :: term()}.

Transfers the binary Bin into the file RemoteFile at the remote server.

Info API

formaterror(Tag)

-spec formaterror(Tag :: atom() | {error, atom()}) -> string().

Given an error return value {error, AtomReason}, this function returns a readable string describing the error.

lpwd(Client)

-spec lpwd(Client :: client()) -> {ok, Dir :: string()}.

Returns the current working directory at the local client.

ls(Client)

-spec ls(Client :: client()) -> {ok, Listing :: string()} | {error, Reason :: term()}.

Equivalent to ls/2.

ls(Client, Dir)

-spec ls(Client :: client(), Dir :: string()) -> {ok, Listing :: string()} | {error, Reason :: term()}.

Returns a list of files in long format.

Dir can be a directory or a file. The Dir string can contain wildcards.

ls/1 implies the current remote directory of the user.

The format of Listing depends on the operating system. On UNIX, it is typically produced from the output of the ls -l shell command.

nlist(Client)

-spec nlist(Client :: client()) -> {ok, Listing :: string()} | {error, Reason :: term()}.

Equivalent to nlist/2.

nlist(Client, Pathname)

-spec nlist(Client :: client(), Pathname :: string()) ->
               {ok, Listing :: string()} | {error, Reason :: term()}.

Returns a list of files in short format.

Pathname can be a directory or a file. The Pathname string can contain wildcards.

nlist/1 implies the current remote directory of the user.

The format of Listing is a stream of filenames where each filename is separated by <CRLF> or <NL>. Contrary to function ls, the purpose of nlist is to enable a program to process filename information automatically.

pwd(Client)

-spec pwd(Client :: client()) -> {ok, Dir :: string()} | {error, Reason :: term()}.

Returns the current working directory at the remote server.

Update API

append(Client, LocalFileName)

-spec append(Client :: client(), LocalFileName :: file:filename()) -> ok | {error, Reason :: term()}.

Equivalent to append/3.

append(Pid, LocalFileName, RemoteFileName)

-spec append(Pid :: pid(), LocalFileName :: file:filename(), RemoteFileName :: file:filename()) ->
                ok | {error, Reason :: term()}.

Transfers the file LocalFile to the remote server. If RemoteFile is specified, the name of the remote file that the file is appended to is set to RemoteFile, otherwise to LocalFile. If the file does not exists, it is created.

append_bin(Pid, Bin, RemoteFile)

-spec append_bin(Pid :: pid(), Bin :: binary(), RemoteFile :: string()) ->
                    ok | {error, Reason :: term()}.

Transfers the binary Bin to the remote server and appends it to the file RemoteFile. If the file does not exist, it is created.

cd(Client, Dir)

-spec cd(Client :: client(), Dir :: string()) -> ok | {error, Reason :: term()}.

Changes the working directory at the remote server to Dir.

delete(Client, File)

-spec delete(Client :: client(), File :: string()) -> ok | {error, Reason :: term()}.

Deletes the file File at the remote server.

lcd(Client, Dir)

-spec lcd(Client :: client(), Dir :: string()) -> ok | {error, Reason :: term()}.

Changes the working directory to Dir for the local client.

mkdir(Client, Dir)

-spec mkdir(Client :: client(), Dir :: string()) -> ok | {error, Reason :: term()}.

Creates the directory Dir at the remote server.

rename(Client, Old, New)

-spec rename(Client :: client(), Old :: string(), New :: string()) -> ok | {error, Reason :: term()}.

Renames Old to New at the remote server.

rmdir(Client, Dir)

-spec rmdir(Client :: client(), Dir :: string()) -> ok | {error, Reason :: term()}.

Removes directory Dir at the remote server.

type(Client, Type)

-spec type(Client :: client(), Type :: ascii | binary) -> ok | {error, Reason :: term()}.

Sets the file transfer type to ascii or binary. When an FTP session is opened, the default transfer type of the server is used, most often ascii, which is default according to RFC 959.

Functions

quote(Client, Cmd)

-spec quote(Client :: client(), Cmd :: string()) -> [FTPLine :: string()].

Note

The telnet end of line characters, from the FTP protocol definition, CRLF, for example, "\\r\\n" has been removed.

Sends an arbitrary FTP command and returns verbatim a list of the lines sent back by the FTP server. This function is intended to give application accesses to FTP commands that are server-specific or that cannot be provided by this FTP client.

Note

FTP commands requiring a data connection cannot be successfully issued with this function.